diff options
author | Valentin Popov <info@valentineus.link> | 2020-07-19 19:14:20 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2020-07-19 19:14:20 +0300 |
commit | 7d078315d6f592de968fbaf9959a2dbc2f59ddfe (patch) | |
tree | 73d12f5d62ae3099a471197126cb07e42ddf5d4b | |
parent | 400862f5eea453730b556b34faf1bb45b03a6751 (diff) | |
download | php-epg-service-7d078315d6f592de968fbaf9959a2dbc2f59ddfe.tar.xz php-epg-service-7d078315d6f592de968fbaf9959a2dbc2f59ddfe.zip |
Updated genre entity
Signed-off-by: Valentin Popov <info@valentineus.link>
-rw-r--r-- | src/Entities/GenreEntity.php | 26 | ||||
-rw-r--r-- | tests/Entities/GenreEntityTest.php | 8 |
2 files changed, 15 insertions, 19 deletions
diff --git a/src/Entities/GenreEntity.php b/src/Entities/GenreEntity.php index 61e11ba..ee81041 100644 --- a/src/Entities/GenreEntity.php +++ b/src/Entities/GenreEntity.php @@ -20,11 +20,10 @@ declare(strict_types = 1); namespace EPGService\Entities; use RuntimeException; -use function is_int; use function is_string; /** - * @property-read int $id + * @property-read string $id * @property-read string $lang * @property-read string $name * @property-read string $version @@ -35,9 +34,9 @@ use function is_string; */ final class GenreEntity { /** - * @var int + * @var string */ - private int $id; + private string $id; /** * @var string @@ -55,20 +54,17 @@ final class GenreEntity { private string $version; /** - * @param int $id - * @param string $lang - * @param string $name - * @param string $version + * @param array $payload */ - private function __construct(int $id, string $lang, string $name, string $version) { - $this->id = $id; - $this->lang = $lang; - $this->name = $name; - $this->version = $version; + private function __construct(array $payload) { + $this->id = $payload['id']; + $this->lang = $payload['lang']; + $this->name = $payload['name']; + $this->version = $payload['version']; } public static function create(array $payload): GenreEntity { - if (!is_int($payload['id'])) { + if (!is_string($payload['id'])) { throw new RuntimeException('blah-blah-blah'); } @@ -84,7 +80,7 @@ final class GenreEntity { throw new RuntimeException('blah-blah-blah'); } - return new GenreEntity($payload['id'], $payload['lang'], $payload['name'], $payload['version']); + return new GenreEntity($payload); } /** diff --git a/tests/Entities/GenreEntityTest.php b/tests/Entities/GenreEntityTest.php index 0b1b12c..278fb68 100644 --- a/tests/Entities/GenreEntityTest.php +++ b/tests/Entities/GenreEntityTest.php @@ -32,10 +32,10 @@ final class GenreEntityTest extends TestCase { public function testCreateEntity(): void { $faker = Faker::create(); - $id = $faker->numberBetween(1, 999); - $lang = $faker->languageCode; - $name = $faker->word; - $version = $faker->sha256; + $id = $faker->unique()->sha256; + $lang = $faker->unique()->sha256; + $name = $faker->unique()->sha256; + $version = $faker->unique()->sha256; $entity = GenreEntity::create(compact('id', 'lang', 'name', 'version')); |