From c71f8906181669f33c87614eb78bced95ce16938 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 12:35:48 +0400 Subject: Added .gitignore file Signed-off-by: Valentin Popov --- .gitignore | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..843e828 --- /dev/null +++ b/.gitignore @@ -0,0 +1,111 @@ +### Composer ### + +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock + +### Git ### + +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### Linux ### + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### PHPUnit ### + +# Covers PHPUnit +# Reference: https://phpunit.de/ + +# Generated files +.phpunit.result.cache + +# PHPUnit +/app/phpunit.xml +/phpunit.xml + +# Build data +/build/ + +### Windows ### + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk -- cgit v1.2.3 From 33ce2e1b48f27709bbf7c243c029a7f8ca50e63a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 12:37:34 +0400 Subject: Added .gitignore file Signed-off-by: Valentin Popov --- composer.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1260768 --- /dev/null +++ b/composer.json @@ -0,0 +1,14 @@ +{ + "name": "valentineus/epg-service", + "description": "Description", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Valentin Popov", + "email": "info@valentineus.link" + } + ], + "minimum-stability": "alpha", + "require": {} +} -- cgit v1.2.3 From 2c59b907b8f4617afcf0c78e4069aedbbbd33939 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 13:23:59 +0400 Subject: Added service environment Signed-off-by: Valentin Popov --- src/Environments/ServiceEnvironment.php | 42 +++++++++++++++++++++++++++ tests/Environments/ServiceEnvironmentTest.php | 41 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/Environments/ServiceEnvironment.php create mode 100644 tests/Environments/ServiceEnvironmentTest.php diff --git a/src/Environments/ServiceEnvironment.php b/src/Environments/ServiceEnvironment.php new file mode 100644 index 0000000..c24f6a6 --- /dev/null +++ b/src/Environments/ServiceEnvironment.php @@ -0,0 +1,42 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Environments + */ +class ServiceEnvironment { + /** + * @var string + */ + private const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s/%s'; + + /** + * @param string $key + * @param string $method + * + * @return string + */ + public static function getUrl(string $key, string $method = ''): string { + return sprintf(self::BASE_URL, $key, $method); + } +} diff --git a/tests/Environments/ServiceEnvironmentTest.php b/tests/Environments/ServiceEnvironmentTest.php new file mode 100644 index 0000000..faa38da --- /dev/null +++ b/tests/Environments/ServiceEnvironmentTest.php @@ -0,0 +1,41 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Environments + */ +final class ServiceEnvironmentTest extends TestCase { + public function testGetUrl(): void { + $key = Faker::create()->sha256; + $method = Faker::create()->sha256; + + $url = ServiceEnvironment::getUrl($key, $method); + + self::assertStringContainsString($key, $url); + self::assertStringContainsString($method, $url); + } +} -- cgit v1.2.3 From 76e8ed954e2a1c70437fb34a927d1bb1d921d3ce Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 13:54:01 +0400 Subject: Added category entity Signed-off-by: Valentin Popov --- src/Entities/CategoryEntity.php | 114 ++++++++++++++++++++++++++++++++++ tests/Entities/CategoryEntityTest.php | 47 ++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 src/Entities/CategoryEntity.php create mode 100644 tests/Entities/CategoryEntityTest.php diff --git a/src/Entities/CategoryEntity.php b/src/Entities/CategoryEntity.php new file mode 100644 index 0000000..ab1f431 --- /dev/null +++ b/src/Entities/CategoryEntity.php @@ -0,0 +1,114 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities + */ +class CategoryEntity { + /** + * @var int + */ + protected int $id; + + /** + * @var string + */ + protected string $lang; + + /** + * @var string + */ + protected string $name; + + /** + * @var string + */ + protected string $version; + + /** + * @param int $id + * @param string $lang + * @param string $name + * @param string $version + */ + protected function __construct(int $id, string $lang, string $name, string $version) { + $this->id = $id; + $this->lang = $lang; + $this->name = $name; + $this->version = $version; + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\CategoryEntity + * @throws \RuntimeException + */ + public static function create(array $payload): CategoryEntity { + if (!is_int($payload['id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['lang'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['name'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['version'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new CategoryEntity($payload['id'], $payload['lang'], $payload['name'], $payload['version']); + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get(string $name) { + return $this->$name; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \RuntimeException + */ + public function __set(string $name, $value) { + throw new RuntimeException('blah-blah-blah'); + } +} diff --git a/tests/Entities/CategoryEntityTest.php b/tests/Entities/CategoryEntityTest.php new file mode 100644 index 0000000..6ad7bd3 --- /dev/null +++ b/tests/Entities/CategoryEntityTest.php @@ -0,0 +1,47 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Entities + */ +final class CategoryEntityTest extends TestCase { + public function testCreateEntity(): void { + $faker = Faker::create(); + + $id = $faker->numberBetween(1, 999); + $lang = $faker->languageCode; + $name = $faker->word; + $version = $faker->sha256; + + $entity = CategoryEntity::create(compact('id', 'lang', 'name', 'version')); + + self::assertEquals($id, $entity->id); + self::assertEquals($lang, $entity->lang); + self::assertEquals($name, $entity->name); + self::assertEquals($version, $entity->version); + } +} -- cgit v1.2.3 From ecabedfa1f7a8cbba7a522ca8440b82063d04686 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 14:57:48 +0400 Subject: Updated service environment Signed-off-by: Valentin Popov --- src/Environments/ServiceEnvironment.php | 26 +++++++++++++++++++++++--- tests/Environments/ServiceEnvironmentTest.php | 12 ++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Environments/ServiceEnvironment.php b/src/Environments/ServiceEnvironment.php index c24f6a6..ade87c1 100644 --- a/src/Environments/ServiceEnvironment.php +++ b/src/Environments/ServiceEnvironment.php @@ -28,15 +28,35 @@ class ServiceEnvironment { /** * @var string */ - private const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s/%s'; + protected const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s/%s'; + + /** + * @var string + */ + private string $key; + + /** + * @param string $key + */ + protected function __construct(string $key) { + $this->key = $key; + } /** * @param string $key + * + * @return \EPGService\Environments\ServiceEnvironment + */ + public static function create(string $key): ServiceEnvironment { + return new ServiceEnvironment($key); + } + + /** * @param string $method * * @return string */ - public static function getUrl(string $key, string $method = ''): string { - return sprintf(self::BASE_URL, $key, $method); + public function getUrl(string $method = ''): string { + return sprintf(self::BASE_URL, $this->key, $method); } } diff --git a/tests/Environments/ServiceEnvironmentTest.php b/tests/Environments/ServiceEnvironmentTest.php index faa38da..792fcd1 100644 --- a/tests/Environments/ServiceEnvironmentTest.php +++ b/tests/Environments/ServiceEnvironmentTest.php @@ -29,13 +29,17 @@ use PHPUnit\Framework\TestCase; * @package Tests\Environments */ final class ServiceEnvironmentTest extends TestCase { - public function testGetUrl(): void { + public function testGetUrlWithMethod(): void { $key = Faker::create()->sha256; $method = Faker::create()->sha256; - - $url = ServiceEnvironment::getUrl($key, $method); - + $url = ServiceEnvironment::create($key)->getUrl($method); self::assertStringContainsString($key, $url); self::assertStringContainsString($method, $url); } + + public function testGetUrlWithoutMethod(): void { + $key = Faker::create()->sha256; + $url = ServiceEnvironment::create($key)->getUrl(); + self::assertStringContainsString($key, $url); + } } -- cgit v1.2.3 From 63ba3120648cbcde5ebd818f90ad832539b1a9af Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 15:11:50 +0400 Subject: Updated method “getUrl()” MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Valentin Popov --- src/Environments/ServiceEnvironment.php | 8 +++----- tests/Environments/ServiceEnvironmentTest.php | 10 +--------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Environments/ServiceEnvironment.php b/src/Environments/ServiceEnvironment.php index ade87c1..004586f 100644 --- a/src/Environments/ServiceEnvironment.php +++ b/src/Environments/ServiceEnvironment.php @@ -28,7 +28,7 @@ class ServiceEnvironment { /** * @var string */ - protected const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s/%s'; + protected const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s'; /** * @var string @@ -52,11 +52,9 @@ class ServiceEnvironment { } /** - * @param string $method - * * @return string */ - public function getUrl(string $method = ''): string { - return sprintf(self::BASE_URL, $this->key, $method); + public function getUrl(): string { + return sprintf(self::BASE_URL, $this->key); } } diff --git a/tests/Environments/ServiceEnvironmentTest.php b/tests/Environments/ServiceEnvironmentTest.php index 792fcd1..b14d909 100644 --- a/tests/Environments/ServiceEnvironmentTest.php +++ b/tests/Environments/ServiceEnvironmentTest.php @@ -29,15 +29,7 @@ use PHPUnit\Framework\TestCase; * @package Tests\Environments */ final class ServiceEnvironmentTest extends TestCase { - public function testGetUrlWithMethod(): void { - $key = Faker::create()->sha256; - $method = Faker::create()->sha256; - $url = ServiceEnvironment::create($key)->getUrl($method); - self::assertStringContainsString($key, $url); - self::assertStringContainsString($method, $url); - } - - public function testGetUrlWithoutMethod(): void { + public function testGetUrl(): void { $key = Faker::create()->sha256; $url = ServiceEnvironment::create($key)->getUrl(); self::assertStringContainsString($key, $url); -- cgit v1.2.3 From f621cf9ceeabe3b6720a33a276b2ff6bd221c9dd Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:12:37 +0400 Subject: Utility of get key Signed-off-by: Valentin Popov --- tests/Utilities/GetKeyUtility.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/Utilities/GetKeyUtility.php diff --git a/tests/Utilities/GetKeyUtility.php b/tests/Utilities/GetKeyUtility.php new file mode 100644 index 0000000..a72601e --- /dev/null +++ b/tests/Utilities/GetKeyUtility.php @@ -0,0 +1,39 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Utilities + */ +final class GetKeyUtility { + /** + * @return string + */ + public static function get(): string { + $result = Dotenv::createImmutable(dirname(__DIR__, 2))->load(); + + return $result['EPG_SERVICE_KEY'] ?? ''; + } +} -- cgit v1.2.3 From 81687eb05afd20022459054390186a7d3314822b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:14:14 +0400 Subject: Utility of get environment Signed-off-by: Valentin Popov --- tests/Utilities/GetServiceEnvironment.php | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/Utilities/GetServiceEnvironment.php diff --git a/tests/Utilities/GetServiceEnvironment.php b/tests/Utilities/GetServiceEnvironment.php new file mode 100644 index 0000000..cba08ae --- /dev/null +++ b/tests/Utilities/GetServiceEnvironment.php @@ -0,0 +1,38 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Utilities + */ +final class GetServiceEnvironment { + /** + * @return \EPGService\Environments\ServiceEnvironment + */ + public static function get(): ServiceEnvironment { + $key = GetKeyUtility::get(); + + return ServiceEnvironment::create($key); + } +} -- cgit v1.2.3 From 7640bc1002b7569f5c8bc725708f516a61f2a988 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:16:44 +0400 Subject: Fixed base url Signed-off-by: Valentin Popov --- src/Environments/ServiceEnvironment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Environments/ServiceEnvironment.php b/src/Environments/ServiceEnvironment.php index 004586f..53ab732 100644 --- a/src/Environments/ServiceEnvironment.php +++ b/src/Environments/ServiceEnvironment.php @@ -28,7 +28,7 @@ class ServiceEnvironment { /** * @var string */ - protected const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s'; + protected const BASE_URL = 'http://xmldata.epgservice.ru/EPGService/hs/xmldata/%s/'; /** * @var string -- cgit v1.2.3 From 30bc68e6e2d642ec1a8258de377d46782825f616 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:48:22 +0400 Subject: Added integer parser Signed-off-by: Valentin Popov --- src/Parsers/IntegerParser.php | 36 +++++++++++++++++++++++++++++++++ tests/Parsers/IntegerParserTest.php | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/Parsers/IntegerParser.php create mode 100644 tests/Parsers/IntegerParserTest.php diff --git a/src/Parsers/IntegerParser.php b/src/Parsers/IntegerParser.php new file mode 100644 index 0000000..95df2dd --- /dev/null +++ b/src/Parsers/IntegerParser.php @@ -0,0 +1,36 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Parsers + */ +final class IntegerParser { + /** + * @param mixed $value + * + * @return int|null + */ + public static function get($value): ?int { + return filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE); + } +} diff --git a/tests/Parsers/IntegerParserTest.php b/tests/Parsers/IntegerParserTest.php new file mode 100644 index 0000000..7f5cce7 --- /dev/null +++ b/tests/Parsers/IntegerParserTest.php @@ -0,0 +1,40 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Parsers + */ +final class IntegerParserTest extends TestCase { + public function testInvalid(): void { + self::assertNull(IntegerParser::get(null)); + } + + public function testValid(): void { + $number = Faker::create()->numberBetween(100, 200); + self::assertEquals($number, IntegerParser::get((string) $number)); + } +} -- cgit v1.2.3 From 9682cb058c468329a3273607d2fcb172fdfd9835 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:54:44 +0400 Subject: Added string parser Signed-off-by: Valentin Popov --- src/Parsers/StringParser.php | 40 ++++++++++++++++++++++++++++++++++++++ tests/Parsers/StringParserTest.php | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/Parsers/StringParser.php create mode 100644 tests/Parsers/StringParserTest.php diff --git a/src/Parsers/StringParser.php b/src/Parsers/StringParser.php new file mode 100644 index 0000000..1bc7a60 --- /dev/null +++ b/src/Parsers/StringParser.php @@ -0,0 +1,40 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Parsers + */ +final class StringParser { + /** + * @param $value + * + * @return string|null + */ + public static function get($value): ?string { + $result = filter_var($value, FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE); + + return is_string($result) ? trim($result) : null; + } +} diff --git a/tests/Parsers/StringParserTest.php b/tests/Parsers/StringParserTest.php new file mode 100644 index 0000000..518defb --- /dev/null +++ b/tests/Parsers/StringParserTest.php @@ -0,0 +1,35 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Parsers + */ +final class StringParserTest extends TestCase { + public function testValid(): void { + $string = '

Hello WorldÆØÅ!

'; + self::assertEquals('Hello World!', StringParser::get($string)); + } +} -- cgit v1.2.3 From 5062d35a0d3a6463ef03c8f83fe2f93ac9099a62 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 16:59:38 +0400 Subject: Updated parsers Signed-off-by: Valentin Popov --- src/Parsers/IntegerParser.php | 6 +++--- src/Parsers/StringParser.php | 10 +++------- tests/Parsers/IntegerParserTest.php | 4 ---- tests/Parsers/StringParserTest.php | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Parsers/IntegerParser.php b/src/Parsers/IntegerParser.php index 95df2dd..3eb4ea1 100644 --- a/src/Parsers/IntegerParser.php +++ b/src/Parsers/IntegerParser.php @@ -28,9 +28,9 @@ final class IntegerParser { /** * @param mixed $value * - * @return int|null + * @return int */ - public static function get($value): ?int { - return filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE); + public static function get($value): int { + return filter_var($value, FILTER_VALIDATE_INT); } } diff --git a/src/Parsers/StringParser.php b/src/Parsers/StringParser.php index 1bc7a60..c22d8f1 100644 --- a/src/Parsers/StringParser.php +++ b/src/Parsers/StringParser.php @@ -19,8 +19,6 @@ declare(strict_types = 1); namespace EPGService\Parsers; -use function is_string; - /** * @copyright Copyright © 2020 “Valentin Popov” * @license http://www.apache.org/licenses/LICENSE-2.0 @@ -30,11 +28,9 @@ final class StringParser { /** * @param $value * - * @return string|null + * @return string */ - public static function get($value): ?string { - $result = filter_var($value, FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE); - - return is_string($result) ? trim($result) : null; + public static function get($value): string { + return filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); } } diff --git a/tests/Parsers/IntegerParserTest.php b/tests/Parsers/IntegerParserTest.php index 7f5cce7..56c13ce 100644 --- a/tests/Parsers/IntegerParserTest.php +++ b/tests/Parsers/IntegerParserTest.php @@ -29,10 +29,6 @@ use PHPUnit\Framework\TestCase; * @package Tests\Parsers */ final class IntegerParserTest extends TestCase { - public function testInvalid(): void { - self::assertNull(IntegerParser::get(null)); - } - public function testValid(): void { $number = Faker::create()->numberBetween(100, 200); self::assertEquals($number, IntegerParser::get((string) $number)); diff --git a/tests/Parsers/StringParserTest.php b/tests/Parsers/StringParserTest.php index 518defb..5c1a82b 100644 --- a/tests/Parsers/StringParserTest.php +++ b/tests/Parsers/StringParserTest.php @@ -29,7 +29,7 @@ use PHPUnit\Framework\TestCase; */ final class StringParserTest extends TestCase { public function testValid(): void { - $string = '

Hello WorldÆØÅ!

'; + $string = '

Hello World!

'; self::assertEquals('Hello World!', StringParser::get($string)); } } -- cgit v1.2.3 From c18b1373d03f84d58737712b57efa02e642a1e58 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 19:09:58 +0400 Subject: Added category repository Signed-off-by: Valentin Popov --- src/Repositories/BaseRepository.php | 32 ++++++++ src/Repositories/CategoryRepository.php | 104 ++++++++++++++++++++++++++ tests/Repositories/CategoryRepositoryTest.php | 47 ++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 src/Repositories/BaseRepository.php create mode 100644 src/Repositories/CategoryRepository.php create mode 100644 tests/Repositories/CategoryRepositoryTest.php diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php new file mode 100644 index 0000000..14c9061 --- /dev/null +++ b/src/Repositories/BaseRepository.php @@ -0,0 +1,32 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Repositories + */ +interface BaseRepository { + /** + * @return mixed + */ + public function get(); +} diff --git a/src/Repositories/CategoryRepository.php b/src/Repositories/CategoryRepository.php new file mode 100644 index 0000000..6139168 --- /dev/null +++ b/src/Repositories/CategoryRepository.php @@ -0,0 +1,104 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Repositories + */ +final class CategoryRepository implements BaseRepository { + /** + * @var string + */ + private const METHOD = 'category_list'; + + /** + * @var \GuzzleHttp\Client + */ + private Client $client; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + */ + private function __construct(ServiceEnvironment $environment) { + $this->client = new Client([ + 'base_uri' => $environment->getUrl(), + ]); + } + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * + * @return \EPGService\Repositories\CategoryRepository + */ + public static function create(ServiceEnvironment $environment): CategoryRepository { + return new CategoryRepository($environment); + } + + /** + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + */ + public function get(): array { + $response = $this->client->get(self::METHOD); + $content = $response->getBody()->getContents(); + $xml = simplexml_load_string($content); + + if (is_bool($xml) || !$xml->element instanceof SimpleXMLElement) { + throw new RuntimeException('blah-blah-blah'); + } + + $result = []; + + foreach ($xml->element as $element) { + if (!$element instanceof SimpleXMLElement) { + trigger_error('blah-blah-blah', E_USER_WARNING); + continue; + } + + if (!$element->name instanceof SimpleXMLElement) { + trigger_error('blah-blah-blah', E_USER_WARNING); + continue; + } + + $result[] = CategoryEntity::create([ + 'id' => IntegerParser::get($element['id']), + 'lang' => StringParser::get($element->name['lang']), + 'name' => StringParser::get($element->name), + 'version' => StringParser::get($element['version']), + ]); + } + + return $result; + } +} diff --git a/tests/Repositories/CategoryRepositoryTest.php b/tests/Repositories/CategoryRepositoryTest.php new file mode 100644 index 0000000..f78f5b4 --- /dev/null +++ b/tests/Repositories/CategoryRepositoryTest.php @@ -0,0 +1,47 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Repositories + */ +final class CategoryRepositoryTest extends TestCase { + /** + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function testGetAction(): void { + $env = GetServiceEnvironment::get(); + + foreach (CategoryRepository::create($env)->get() as $category) { + /** @var \EPGService\Entities\CategoryEntity $category */ + + self::assertIsInt($category->id); + self::assertIsString($category->lang); + self::assertIsString($category->name); + self::assertIsString($category->version); + } + } +} -- cgit v1.2.3 From c0d5496035e5ac7ec44a832428a8d651a950903d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 19:13:16 +0400 Subject: Added interface of parser Signed-off-by: Valentin Popov --- src/Parsers/BaseParser.php | 34 ++++++++++++++++++++++++++++++++++ src/Parsers/IntegerParser.php | 2 +- src/Parsers/StringParser.php | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/Parsers/BaseParser.php diff --git a/src/Parsers/BaseParser.php b/src/Parsers/BaseParser.php new file mode 100644 index 0000000..d36508d --- /dev/null +++ b/src/Parsers/BaseParser.php @@ -0,0 +1,34 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Parsers + */ +interface BaseParser { + /** + * @param mixed $value + * + * @return mixed + */ + public static function get($value); +} diff --git a/src/Parsers/IntegerParser.php b/src/Parsers/IntegerParser.php index 3eb4ea1..ba89315 100644 --- a/src/Parsers/IntegerParser.php +++ b/src/Parsers/IntegerParser.php @@ -24,7 +24,7 @@ namespace EPGService\Parsers; * @license http://www.apache.org/licenses/LICENSE-2.0 * @package EPGService\Parsers */ -final class IntegerParser { +final class IntegerParser implements BaseParser { /** * @param mixed $value * diff --git a/src/Parsers/StringParser.php b/src/Parsers/StringParser.php index c22d8f1..8473106 100644 --- a/src/Parsers/StringParser.php +++ b/src/Parsers/StringParser.php @@ -24,7 +24,7 @@ namespace EPGService\Parsers; * @license http://www.apache.org/licenses/LICENSE-2.0 * @package EPGService\Parsers */ -final class StringParser { +final class StringParser implements BaseParser { /** * @param $value * -- cgit v1.2.3 From 6c52322a3cc5fe4036cc7689d60bd47eca402452 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 19:20:43 +0400 Subject: Added genre entity Signed-off-by: Valentin Popov --- src/Entities/GenreEntity.php | 108 +++++++++++++++++++++++++++++++++++++ tests/Entities/GenreEntityTest.php | 47 ++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 src/Entities/GenreEntity.php create mode 100644 tests/Entities/GenreEntityTest.php diff --git a/src/Entities/GenreEntity.php b/src/Entities/GenreEntity.php new file mode 100644 index 0000000..78a9ac0 --- /dev/null +++ b/src/Entities/GenreEntity.php @@ -0,0 +1,108 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities + */ +class GenreEntity { + /** + * @var int + */ + protected int $id; + + /** + * @var string + */ + protected string $lang; + + /** + * @var string + */ + protected string $name; + + /** + * @var string + */ + protected string $version; + + /** + * @param int $id + * @param string $lang + * @param string $name + * @param string $version + */ + protected function __construct(int $id, string $lang, string $name, string $version) { + $this->id = $id; + $this->lang = $lang; + $this->name = $name; + $this->version = $version; + } + + public static function create(array $payload): GenreEntity { + if (!is_int($payload['id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['lang'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['name'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['version'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new GenreEntity($payload['id'], $payload['lang'], $payload['name'], $payload['version']); + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get(string $name) { + return $this->$name; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \RuntimeException + */ + public function __set(string $name, $value) { + throw new RuntimeException('blah-blah-blah'); + } +} diff --git a/tests/Entities/GenreEntityTest.php b/tests/Entities/GenreEntityTest.php new file mode 100644 index 0000000..0b1b12c --- /dev/null +++ b/tests/Entities/GenreEntityTest.php @@ -0,0 +1,47 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Entities + */ +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; + + $entity = GenreEntity::create(compact('id', 'lang', 'name', 'version')); + + self::assertEquals($id, $entity->id); + self::assertEquals($lang, $entity->lang); + self::assertEquals($name, $entity->name); + self::assertEquals($version, $entity->version); + } +} -- cgit v1.2.3 From 721e01511aca0df7a8fdee421ea8d65a5879684b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 19:27:57 +0400 Subject: Added genre repository Signed-off-by: Valentin Popov --- src/Repositories/GenreRepository.php | 103 +++++++++++++++++++++++++++++ tests/Repositories/GenreRepositoryTest.php | 47 +++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 src/Repositories/GenreRepository.php create mode 100644 tests/Repositories/GenreRepositoryTest.php diff --git a/src/Repositories/GenreRepository.php b/src/Repositories/GenreRepository.php new file mode 100644 index 0000000..67c9a4e --- /dev/null +++ b/src/Repositories/GenreRepository.php @@ -0,0 +1,103 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Repositories + */ +final class GenreRepository implements BaseRepository { + /** + * @var string + */ + private const METHOD = 'genre_list'; + + /** + * @var \GuzzleHttp\Client + */ + private Client $client; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + */ + private function __construct(ServiceEnvironment $environment) { + $this->client = new Client([ + 'base_uri' => $environment->getUrl(), + ]); + } + + /** + * @param \EPGService\Environments\ServiceEnvironment $env + * + * @return \EPGService\Repositories\GenreRepository + */ + public static function create(ServiceEnvironment $env): GenreRepository { + return new GenreRepository($env); + } + + /** + * @return \EPGService\Entities\GenreEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + */ + public function get(): array { + $response = $this->client->get(self::METHOD); + $content = $response->getBody()->getContents(); + $xml = simplexml_load_string($content); + + if (is_bool($xml) || !$xml->element instanceof SimpleXMLElement) { + throw new RuntimeException('blah-blah-blah'); + } + + $result = []; + + foreach ($xml->element as $element) { + if (!$element instanceof SimpleXMLElement) { + trigger_error('blah-blah-blah', E_USER_WARNING); + continue; + } + + if (!$element->name instanceof SimpleXMLElement) { + trigger_error('blah-blah-blah', E_USER_WARNING); + continue; + } + + $result[] = GenreEntity::create([ + 'id' => IntegerParser::get($element['id']), + 'lang' => StringParser::get($element->name['lang']), + 'name' => StringParser::get($element->name), + 'version' => StringParser::get($element['version']), + ]); + } + + return $result; + } +} diff --git a/tests/Repositories/GenreRepositoryTest.php b/tests/Repositories/GenreRepositoryTest.php new file mode 100644 index 0000000..94c8a79 --- /dev/null +++ b/tests/Repositories/GenreRepositoryTest.php @@ -0,0 +1,47 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Repositories + */ +final class GenreRepositoryTest extends TestCase { + /** + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function testGetAction(): void { + $env = GetServiceEnvironment::get(); + + foreach (GenreRepository::create($env)->get() as $category) { + /** @var \EPGService\Entities\GenreEntity $category */ + + self::assertIsInt($category->id); + self::assertIsString($category->lang); + self::assertIsString($category->name); + self::assertIsString($category->version); + } + } +} -- cgit v1.2.3 From 42008dbe1bb64e901156560d066f47c2208d9d84 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 15 Jul 2020 22:06:33 +0400 Subject: Marked “final” entities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Valentin Popov --- src/Entities/CategoryEntity.php | 12 ++++++------ src/Entities/GenreEntity.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Entities/CategoryEntity.php b/src/Entities/CategoryEntity.php index ab1f431..af44434 100644 --- a/src/Entities/CategoryEntity.php +++ b/src/Entities/CategoryEntity.php @@ -33,26 +33,26 @@ use function is_string; * @license http://www.apache.org/licenses/LICENSE-2.0 * @package EPGService\Entities */ -class CategoryEntity { +final class CategoryEntity { /** * @var int */ - protected int $id; + private int $id; /** * @var string */ - protected string $lang; + private string $lang; /** * @var string */ - protected string $name; + private string $name; /** * @var string */ - protected string $version; + private string $version; /** * @param int $id @@ -60,7 +60,7 @@ class CategoryEntity { * @param string $name * @param string $version */ - protected function __construct(int $id, string $lang, string $name, string $version) { + private function __construct(int $id, string $lang, string $name, string $version) { $this->id = $id; $this->lang = $lang; $this->name = $name; diff --git a/src/Entities/GenreEntity.php b/src/Entities/GenreEntity.php index 78a9ac0..61e11ba 100644 --- a/src/Entities/GenreEntity.php +++ b/src/Entities/GenreEntity.php @@ -33,26 +33,26 @@ use function is_string; * @license http://www.apache.org/licenses/LICENSE-2.0 * @package EPGService\Entities */ -class GenreEntity { +final class GenreEntity { /** * @var int */ - protected int $id; + private int $id; /** * @var string */ - protected string $lang; + private string $lang; /** * @var string */ - protected string $name; + private string $name; /** * @var string */ - protected string $version; + private string $version; /** * @param int $id @@ -60,7 +60,7 @@ class GenreEntity { * @param string $name * @param string $version */ - protected function __construct(int $id, string $lang, string $name, string $version) { + private function __construct(int $id, string $lang, string $name, string $version) { $this->id = $id; $this->lang = $lang; $this->name = $name; -- cgit v1.2.3 From 964ba206127de4eb904f271fd80db7941653adaa Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 12:14:42 +0400 Subject: Added channel entity Signed-off-by: Valentin Popov --- src/Entities/ChannelEntity.php | 177 +++++++++++++++++++++++++++++++++++ tests/Entities/ChannelEntityTest.php | 70 ++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 src/Entities/ChannelEntity.php create mode 100644 tests/Entities/ChannelEntityTest.php diff --git a/src/Entities/ChannelEntity.php b/src/Entities/ChannelEntity.php new file mode 100644 index 0000000..59fc8ce --- /dev/null +++ b/src/Entities/ChannelEntity.php @@ -0,0 +1,177 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities + */ +final class ChannelEntity { + /** + * @var string + */ + private string $base_id; + + /** + * @var string + */ + private string $epg_id; + + /** + * @var string + */ + private string $geo_data; + + /** + * @var string + */ + private string $href; + + /** + * @var string + */ + private string $icon; + + /** + * @var string + */ + private string $id; + + /** + * @var string + */ + private string $lang; + + /** + * @var string + */ + private string $name; + + /** + * @var string + */ + private string $update_at; + + /** + * @var string + */ + private string $week; + + /** + * @param array $payload + */ + private function __construct(array $payload) { + $this->base_id = $payload['base_id']; + $this->epg_id = $payload['epg_id']; + $this->geo_data = $payload['geo_data']; + $this->href = $payload['href']; + $this->icon = $payload['icon']; + $this->id = $payload['id']; + $this->lang = $payload['lang']; + $this->name = $payload['name']; + $this->update_at = $payload['update_at']; + $this->week = $payload['week']; + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\ChannelEntity + * + * @throws \RuntimeException + */ + public static function create(array $payload): ChannelEntity { + if (!is_string($payload['base_id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['epg_id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['geo_data'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['href'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['icon'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['lang'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['name'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['update_at'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['week'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new ChannelEntity($payload); + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get(string $name) { + return $this->$name; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \RuntimeException + */ + public function __set(string $name, $value) { + throw new RuntimeException('blah-blah-blah'); + } +} diff --git a/tests/Entities/ChannelEntityTest.php b/tests/Entities/ChannelEntityTest.php new file mode 100644 index 0000000..e4f2456 --- /dev/null +++ b/tests/Entities/ChannelEntityTest.php @@ -0,0 +1,70 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Entities + */ +final class ChannelEntityTest extends TestCase { + public function testCreateEntity(): void { + $faker = Factory::create(); + + $base_id = $faker->unique()->sha256; + $epg_id = $faker->unique()->sha256; + $geo_data = $faker->unique()->sha256; + $href = $faker->unique()->sha256; + $icon = $faker->unique()->sha256; + $id = $faker->unique()->sha256; + $lang = $faker->unique()->sha256; + $name = $faker->unique()->sha256; + $update_at = $faker->unique()->sha256; + $week = $faker->unique()->sha256; + + $entity = ChannelEntity::create(compact( + 'base_id', + 'epg_id', + 'geo_data', + 'href', + 'icon', + 'id', + 'lang', + 'name', + 'update_at', + 'week', + )); + + self::assertEquals($base_id, $entity->base_id); + self::assertEquals($epg_id, $entity->epg_id); + self::assertEquals($geo_data, $entity->geo_data); + self::assertEquals($href, $entity->href); + self::assertEquals($icon, $entity->icon); + self::assertEquals($id, $entity->id); + self::assertEquals($lang, $entity->lang); + self::assertEquals($name, $entity->name); + self::assertEquals($update_at, $entity->update_at); + self::assertEquals($week, $entity->week); + } +} -- cgit v1.2.3 From 46f834c9bf7ff890700cef3b05fd2d7ebefb21a0 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 13:42:45 +0400 Subject: Updated channel entity Signed-off-by: Valentin Popov --- src/Entities/ChannelEntity.php | 11 +++++++++++ tests/Entities/ChannelEntityTest.php | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/Entities/ChannelEntity.php b/src/Entities/ChannelEntity.php index 59fc8ce..0d8d3fc 100644 --- a/src/Entities/ChannelEntity.php +++ b/src/Entities/ChannelEntity.php @@ -24,6 +24,7 @@ use function is_string; /** * @property-read string $base_id + * @property-read string $base_name * @property-read string $epg_id * @property-read string $geo_data * @property-read string $href @@ -44,6 +45,11 @@ final class ChannelEntity { */ private string $base_id; + /** + * @var string + */ + private string $base_name; + /** * @var string */ @@ -94,6 +100,7 @@ final class ChannelEntity { */ private function __construct(array $payload) { $this->base_id = $payload['base_id']; + $this->base_name = $payload['base_name']; $this->epg_id = $payload['epg_id']; $this->geo_data = $payload['geo_data']; $this->href = $payload['href']; @@ -117,6 +124,10 @@ final class ChannelEntity { throw new RuntimeException('blah-blah-blah'); } + if (!is_string($payload['base_name'])) { + throw new RuntimeException('blah-blah-blah'); + } + if (!is_string($payload['epg_id'])) { throw new RuntimeException('blah-blah-blah'); } diff --git a/tests/Entities/ChannelEntityTest.php b/tests/Entities/ChannelEntityTest.php index e4f2456..e3c2733 100644 --- a/tests/Entities/ChannelEntityTest.php +++ b/tests/Entities/ChannelEntityTest.php @@ -33,6 +33,7 @@ final class ChannelEntityTest extends TestCase { $faker = Factory::create(); $base_id = $faker->unique()->sha256; + $base_name = $faker->unique()->sha256; $epg_id = $faker->unique()->sha256; $geo_data = $faker->unique()->sha256; $href = $faker->unique()->sha256; @@ -45,6 +46,7 @@ final class ChannelEntityTest extends TestCase { $entity = ChannelEntity::create(compact( 'base_id', + 'base_name', 'epg_id', 'geo_data', 'href', @@ -57,6 +59,7 @@ final class ChannelEntityTest extends TestCase { )); self::assertEquals($base_id, $entity->base_id); + self::assertEquals($base_name, $entity->base_name); self::assertEquals($epg_id, $entity->epg_id); self::assertEquals($geo_data, $entity->geo_data); self::assertEquals($href, $entity->href); -- cgit v1.2.3 From 82584345f6340d83008bed2eb35b3600da925135 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 13:57:33 +0400 Subject: Added channel repository Signed-off-by: Valentin Popov --- src/Repositories/ChannelRepository.php | 104 +++++++++++++++++++++++++++ tests/Repositories/ChannelRepositoryTest.php | 51 +++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 src/Repositories/ChannelRepository.php create mode 100644 tests/Repositories/ChannelRepositoryTest.php diff --git a/src/Repositories/ChannelRepository.php b/src/Repositories/ChannelRepository.php new file mode 100644 index 0000000..4a400f2 --- /dev/null +++ b/src/Repositories/ChannelRepository.php @@ -0,0 +1,104 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Repositories + */ +final class ChannelRepository implements BaseRepository { + /** + * @var string + */ + private const METHOD = 'index'; + + /** + * @var \GuzzleHttp\Client + */ + private Client $client; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + */ + private function __construct(ServiceEnvironment $environment) { + $this->client = new Client([ + 'base_uri' => $environment->getUrl(), + ]); + } + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * + * @return \EPGService\Repositories\ChannelRepository + */ + public static function create(ServiceEnvironment $environment): ChannelRepository { + return new ChannelRepository($environment); + } + + /** + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + */ + public function get(): array { + $response = $this->client->get(self::METHOD); + $content = $response->getBody()->getContents(); + $xml = simplexml_load_string($content); + + if (is_bool($xml) || !$xml->channel instanceof SimpleXMLElement) { + throw new RuntimeException('blah-blah-blah'); + } + + $result = []; + + foreach ($xml->channel as $element) { + if (!$element instanceof SimpleXMLElement) { + trigger_error('blah-blah-blah', E_USER_WARNING); + continue; + } + + $result[] = ChannelEntity::create([ + 'base_id' => StringParser::get($element->{'base-channel'}), + 'base_name' => StringParser::get($element->{'base-channel'}['id']), + 'epg_id' => StringParser::get($element['epgsrvc_id']), + 'geo_data' => StringParser::get($element->{'geo-data'}), + 'href' => StringParser::get($element->href), + 'icon' => StringParser::get($element->icon['src']), + 'id' => StringParser::get($element['id']), + 'lang' => StringParser::get($element->{'display-name'}['lang']), + 'name' => StringParser::get($element->{'base-channel'}), + 'update_at' => StringParser::get($element->update), + 'week' => StringParser::get($element->week), + ]); + } + + return $result; + } +} diff --git a/tests/Repositories/ChannelRepositoryTest.php b/tests/Repositories/ChannelRepositoryTest.php new file mode 100644 index 0000000..2843a8b --- /dev/null +++ b/tests/Repositories/ChannelRepositoryTest.php @@ -0,0 +1,51 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Repositories + */ +final class ChannelRepositoryTest extends TestCase { + public function testGetAction(): void { + $env = GetServiceEnvironment::get(); + + foreach (ChannelRepository::create($env)->get() as $channel) { + /** @var \EPGService\Entities\ChannelEntity $channel */ + + self::assertIsString($channel->base_id); + self::assertIsString($channel->base_name); + self::assertIsString($channel->epg_id); + self::assertIsString($channel->geo_data); + self::assertIsString($channel->href); + self::assertIsString($channel->icon); + self::assertIsString($channel->id); + self::assertIsString($channel->lang); + self::assertIsString($channel->name); + self::assertIsString($channel->update_at); + self::assertIsString($channel->week); + } + } +} -- cgit v1.2.3 From d54c1d65403c7694eea5c7c84b5ea0e3541d410d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 13:57:52 +0400 Subject: Updated test genre repository Signed-off-by: Valentin Popov --- tests/Repositories/GenreRepositoryTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Repositories/GenreRepositoryTest.php b/tests/Repositories/GenreRepositoryTest.php index 94c8a79..1598bbd 100644 --- a/tests/Repositories/GenreRepositoryTest.php +++ b/tests/Repositories/GenreRepositoryTest.php @@ -35,13 +35,13 @@ final class GenreRepositoryTest extends TestCase { public function testGetAction(): void { $env = GetServiceEnvironment::get(); - foreach (GenreRepository::create($env)->get() as $category) { - /** @var \EPGService\Entities\GenreEntity $category */ + foreach (GenreRepository::create($env)->get() as $genre) { + /** @var \EPGService\Entities\GenreEntity $genre */ - self::assertIsInt($category->id); - self::assertIsString($category->lang); - self::assertIsString($category->name); - self::assertIsString($category->version); + self::assertIsInt($genre->id); + self::assertIsString($genre->lang); + self::assertIsString($genre->name); + self::assertIsString($genre->version); } } } -- cgit v1.2.3 From 6d354e6a7791026b4a45e5e20963b10ed1a8bfbe Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 15:32:14 +0400 Subject: Added credit entity Signed-off-by: Valentin Popov --- src/Entities/Program/CreditEntity.php | 89 +++++++++++++++++++++++++++++ tests/Entities/Program/CreditEntityTest.php | 43 ++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 src/Entities/Program/CreditEntity.php create mode 100644 tests/Entities/Program/CreditEntityTest.php diff --git a/src/Entities/Program/CreditEntity.php b/src/Entities/Program/CreditEntity.php new file mode 100644 index 0000000..f7088ea --- /dev/null +++ b/src/Entities/Program/CreditEntity.php @@ -0,0 +1,89 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities\Program + */ +final class CreditEntity { + /** + * @var string + */ + private string $name; + + /** + * @var string + */ + private string $type; + + /** + * @param array $payload + */ + private function __construct(array $payload) { + $this->name = $payload['name']; + $this->type = $payload['type']; + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\Program\CreditEntity + * + * @throws \RuntimeException + */ + public static function create(array $payload): CreditEntity { + if (!is_string($payload['name'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['type'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new CreditEntity($payload); + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get(string $name) { + return $this->$name; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \RuntimeException + */ + public function __set(string $name, $value) { + throw new RuntimeException('blah-blah-blah'); + } +} diff --git a/tests/Entities/Program/CreditEntityTest.php b/tests/Entities/Program/CreditEntityTest.php new file mode 100644 index 0000000..3c80300 --- /dev/null +++ b/tests/Entities/Program/CreditEntityTest.php @@ -0,0 +1,43 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Entities\Program + */ +final class CreditEntityTest extends TestCase { + public function testCreateEntity(): void { + $faker = Faker::create(); + + $name = $faker->unique()->sha256; + $type = $faker->unique()->sha256; + + $entity = CreditEntity::create(compact('name', 'type')); + + self::assertEquals($name, $entity->name); + self::assertEquals($type, $entity->type); + } +} -- cgit v1.2.3 From f01649b2e18c662a63a38315e8e403fdb2db5a4d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 15:48:46 +0400 Subject: Added get credit entity utility Signed-off-by: Valentin Popov --- tests/Utilities/GetCreditEntityUtility.php | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/Utilities/GetCreditEntityUtility.php diff --git a/tests/Utilities/GetCreditEntityUtility.php b/tests/Utilities/GetCreditEntityUtility.php new file mode 100644 index 0000000..f46b176 --- /dev/null +++ b/tests/Utilities/GetCreditEntityUtility.php @@ -0,0 +1,39 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Utilities + */ +final class GetCreditEntityUtility { + public static function get(): CreditEntity { + $faker = Faker::create(); + + return CreditEntity::create([ + 'name' => $faker->unique()->sha256, + 'type' => $faker->unique()->sha256, + ]); + } +} -- cgit v1.2.3 From 74cde415cfa48d318105b301df9c516da0857e9e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 17 Jul 2020 15:54:59 +0400 Subject: Added program entity Signed-off-by: Valentin Popov --- src/Entities/ProgramEntity.php | 223 +++++++++++++++++++++++++++++++++++ tests/Entities/ProgramEntityTest.php | 83 +++++++++++++ 2 files changed, 306 insertions(+) create mode 100644 src/Entities/ProgramEntity.php create mode 100644 tests/Entities/ProgramEntityTest.php diff --git a/src/Entities/ProgramEntity.php b/src/Entities/ProgramEntity.php new file mode 100644 index 0000000..a789de9 --- /dev/null +++ b/src/Entities/ProgramEntity.php @@ -0,0 +1,223 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities + */ +final class ProgramEntity { + /** + * @var string[] + */ + private array $categories; + + /** + * @var string + */ + private string $channel_id; + + /** + * @var string[] + */ + private array $countries; + + /** + * @var \EPGService\Entities\Program\CreditEntity[] + */ + private array $credits; + + /** + * @var \DateTime + */ + private DateTime $date; + + /** + * @var string + */ + private string $description; + + /** + * @var string[] + */ + private array $icons; + + /** + * @var string + */ + private string $parents_guide; + + /** + * @var string[] + */ + private array $productions; + + /** + * @var \DateTime + */ + private DateTime $start; + + /** + * @var \DateTime + */ + private DateTime $stop; + + /** + * @var string + */ + private string $sub_title; + + /** + * @var string + */ + private string $title; + + /** + * @var string + */ + private string $year; + + /** + * @param array $payload + */ + private function __construct(array $payload) { + $this->categories = $payload['categories']; + $this->channel_id = $payload['channel_id']; + $this->countries = $payload['countries']; + $this->credits = $payload['credits']; + $this->date = $payload['date']; + $this->description = $payload['description']; + $this->icons = $payload['icons']; + $this->parents_guide = $payload['parents_guide']; + $this->productions = $payload['productions']; + $this->start = $payload['start']; + $this->stop = $payload['stop']; + $this->sub_title = $payload['sub_title']; + $this->title = $payload['title']; + $this->year = $payload['year']; + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\ProgramEntity + * + * @throws \RuntimeException + */ + public static function create(array $payload): ProgramEntity { + if (!is_array($payload['categories'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['channel_id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_array($payload['countries'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_array($payload['credits'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!$payload['date'] instanceof DateTime) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['description'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_array($payload['icons'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['parents_guide'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_array($payload['productions'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!$payload['start'] instanceof DateTime) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!$payload['stop'] instanceof DateTime) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['sub_title'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['title'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['year'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new ProgramEntity($payload); + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get(string $name) { + return $this->$name; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \RuntimeException + */ + public function __set(string $name, $value) { + throw new RuntimeException('blah-blah-blah'); + } +} diff --git a/tests/Entities/ProgramEntityTest.php b/tests/Entities/ProgramEntityTest.php new file mode 100644 index 0000000..c36e283 --- /dev/null +++ b/tests/Entities/ProgramEntityTest.php @@ -0,0 +1,83 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Entities + */ +final class ProgramEntityTest extends TestCase { + public function testCreateEntity(): void { + $faker = Faker::create(); + + $categories = [$faker->unique()->sha256]; + $channel_id = $faker->unique()->sha256; + $countries = [$faker->unique()->sha256]; + $credits = [GetCreditEntityUtility::get()]; + $date = $faker->unique()->dateTime; + $description = $faker->unique()->sha256; + $icons = [$faker->unique()->sha256]; + $parents_guide = $faker->unique()->sha256; + $productions = [$faker->unique()->sha256]; + $start = $faker->unique()->dateTime; + $stop = $faker->unique()->dateTime; + $sub_title = $faker->unique()->sha256; + $title = $faker->unique()->sha256; + $year = $faker->unique()->sha256; + + $entity = ProgramEntity::create(compact( + 'categories', + 'channel_id', + 'countries', + 'credits', + 'date', + 'description', + 'icons', + 'parents_guide', + 'productions', + 'start', + 'stop', + 'sub_title', + 'title', + 'year' + )); + + self::assertEquals($categories, $entity->categories); + self::assertEquals($channel_id, $entity->channel_id); + self::assertEquals($countries[0], $entity->countries[0]); + self::assertEquals($credits[0]->name, $entity->credits[0]->name); + self::assertEquals($date->getTimestamp(), $entity->date->getTimestamp()); + self::assertEquals($description, $entity->description); + self::assertEquals($icons[0], $entity->icons[0]); + self::assertEquals($parents_guide, $entity->parents_guide); + self::assertEquals($productions[0], $entity->productions[0]); + self::assertEquals($start->getTimestamp(), $entity->start->getTimestamp()); + self::assertEquals($stop->getTimestamp(), $entity->stop->getTimestamp()); + self::assertEquals($sub_title, $entity->sub_title); + self::assertEquals($title, $entity->title); + self::assertEquals($year, $entity->year); + } +} -- cgit v1.2.3 From a223adade6e734d97787f3ca486970877f08af1e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 15:42:17 +0400 Subject: Added program repository Signed-off-by: Valentin Popov --- src/Repositories/ProgramRepository.php | 176 +++++++++++++++++++++++++++ tests/Repositories/ProgramRepositoryTest.php | 52 ++++++++ 2 files changed, 228 insertions(+) create mode 100644 src/Repositories/ProgramRepository.php create mode 100644 tests/Repositories/ProgramRepositoryTest.php diff --git a/src/Repositories/ProgramRepository.php b/src/Repositories/ProgramRepository.php new file mode 100644 index 0000000..494b957 --- /dev/null +++ b/src/Repositories/ProgramRepository.php @@ -0,0 +1,176 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Repositories + */ +final class ProgramRepository implements BaseRepository { + /** + * @var string + */ + private const METHOD = 'file/%s'; + + /** + * @var string + */ + private string $channel_id; + + /** + * @var \GuzzleHttp\Client + */ + private Client $client; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * @param string $channel_id + */ + private function __construct(ServiceEnvironment $environment, string $channel_id) { + $this->channel_id = $channel_id; + + $this->client = new Client([ + 'base_uri' => $environment->getUrl(), + ]); + } + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * @param string $channel_id + * + * @return \EPGService\Repositories\ProgramRepository + */ + public static function create(ServiceEnvironment $environment, string $channel_id): ProgramRepository { + return new ProgramRepository($environment, $channel_id); + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\Program\CreditEntity[] + * + * @throws \RuntimeException + */ + private static function getCreditEntities(array $payload): array { + return array_map(static function (array $value): CreditEntity { + return CreditEntity::create($value); + }, $payload); + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\ProgramEntity + * + * @throws \RuntimeException + * @throws \Exception + */ + private static function getProgramEntity(array $payload): ProgramEntity { + $data = []; + + foreach ($payload as $name => $value) { + switch ($name) { + case 'category': + $data['categories'] = $value; + break; + case 'channel': + $data['channel_id'] = $value; + break; + case 'country': + $data['countries'] = $value; + break; + case 'credits': + $data['credits'] = self::getCreditEntities($value); + break; + case 'date': + $data['date'] = new DateTime($value); + break; + case 'desc': + $data['description'] = $value; + break; + case 'icon': + $data['icons'] = $value; + break; + case 'pg': + $data['parents_guide'] = $value; + break; + case 'production': + $data['productions'] = $value; + break; + case 'start': + $data['start'] = new DateTime($value); + break; + case 'stop': + $data['stop'] = new DateTime($value); + break; + case 'sub_title': + $data['sub_title'] = $value; + break; + case 'title': + $data['title'] = $value; + break; + case 'year': + $data['year'] = $value; + break; + default: + trigger_error('blah-blah-blah', E_USER_WARNING); + break; + } + } + + return ProgramEntity::create($data); + } + + /** + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function get(): array { + $uri = sprintf(self::METHOD, $this->channel_id); + $response = $this->client->get($uri); + + $content = $response->getBody()->getContents(); + $json = json_decode($content, true, 512, JSON_THROW_ON_ERROR); + + if (!is_array($json) || !is_array($json['programms'])) { + throw new RuntimeException('blah-blah-blah'); + } + + $result = []; + + foreach ($json['programms'] as $program) { + $result[] = self::getProgramEntity($program); + } + + return $result; + } +} diff --git a/tests/Repositories/ProgramRepositoryTest.php b/tests/Repositories/ProgramRepositoryTest.php new file mode 100644 index 0000000..f8a32d7 --- /dev/null +++ b/tests/Repositories/ProgramRepositoryTest.php @@ -0,0 +1,52 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Repositories + */ +final class ProgramRepositoryTest extends TestCase { + /** + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function testGetAction(): void { + $env = GetServiceEnvironment::get(); + $channels = ChannelRepository::create($env)->get(); + $channel = array_shift($channels); + + foreach (ProgramRepository::create($env, $channel->id)->get() as $program) { + /** @var \EPGService\Entities\ProgramEntity $program */ + + self::assertNotEmpty($program->channel_id); + self::assertNotEmpty($program->start); + self::assertNotEmpty($program->stop); + self::assertNotEmpty($program->title); + } + } +} -- cgit v1.2.3 From 9d6e3525afeb1a396f78e05c8c8957860a9c4a41 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 15:42:37 +0400 Subject: Updated program entity Signed-off-by: Valentin Popov --- src/Entities/ProgramEntity.php | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/Entities/ProgramEntity.php b/src/Entities/ProgramEntity.php index a789de9..04017c6 100644 --- a/src/Entities/ProgramEntity.php +++ b/src/Entities/ProgramEntity.php @@ -25,20 +25,20 @@ use function is_array; use function is_string; /** - * @property-read \EPGService\Entities\Program\CreditEntity[] $credits - * @property-read \DateTime $date - * @property-read \DateTime $start - * @property-read \DateTime $stop - * @property-read string $channel_id - * @property-read string $description - * @property-read string $parents_guide - * @property-read string $sub_title - * @property-read string $title - * @property-read string $year - * @property-read string[] $categories - * @property-read string[] $countries - * @property-read string[] $icons - * @property-read string[] $productions + * @property-read \EPGService\Entities\Program\CreditEntity[]|null $credits + * @property-read \DateTime $date + * @property-read \DateTime $start + * @property-read \DateTime $stop + * @property-read string $channel_id + * @property-read string|null $description + * @property-read string|null $parents_guide + * @property-read string|null $sub_title + * @property-read string $title + * @property-read string|null $year + * @property-read string[]|null $categories + * @property-read string[]|null $countries + * @property-read string[]|null $icons + * @property-read string[]|null $productions * * @copyright Copyright © 2020 “Valentin Popov” * @license http://www.apache.org/licenses/LICENSE-2.0 @@ -46,9 +46,9 @@ use function is_string; */ final class ProgramEntity { /** - * @var string[] + * @var string[]|null */ - private array $categories; + private ?array $categories; /** * @var string @@ -56,14 +56,14 @@ final class ProgramEntity { private string $channel_id; /** - * @var string[] + * @var string[]|null */ - private array $countries; + private ?array $countries; /** - * @var \EPGService\Entities\Program\CreditEntity[] + * @var \EPGService\Entities\Program\CreditEntity[]|null */ - private array $credits; + private ?array $credits; /** * @var \DateTime @@ -71,24 +71,24 @@ final class ProgramEntity { private DateTime $date; /** - * @var string + * @var string|null */ - private string $description; + private ?string $description; /** - * @var string[] + * @var string[]|null */ - private array $icons; + private ?array $icons; /** - * @var string + * @var string|null */ - private string $parents_guide; + private ?string $parents_guide; /** - * @var string[] + * @var string[]|null */ - private array $productions; + private ?array $productions; /** * @var \DateTime @@ -101,9 +101,9 @@ final class ProgramEntity { private DateTime $stop; /** - * @var string + * @var string|null */ - private string $sub_title; + private ?string $sub_title; /** * @var string @@ -111,28 +111,28 @@ final class ProgramEntity { private string $title; /** - * @var string + * @var string|null */ - private string $year; + private ?string $year; /** * @param array $payload */ private function __construct(array $payload) { - $this->categories = $payload['categories']; + $this->categories = $payload['categories'] ?? null; $this->channel_id = $payload['channel_id']; - $this->countries = $payload['countries']; - $this->credits = $payload['credits']; + $this->countries = $payload['countries'] ?? null; + $this->credits = $payload['credits'] ?? null; $this->date = $payload['date']; - $this->description = $payload['description']; - $this->icons = $payload['icons']; - $this->parents_guide = $payload['parents_guide']; - $this->productions = $payload['productions']; + $this->description = $payload['description'] ?? null; + $this->icons = $payload['icons'] ?? null; + $this->parents_guide = $payload['parents_guide'] ?? null; + $this->productions = $payload['productions'] ?? null; $this->start = $payload['start']; $this->stop = $payload['stop']; - $this->sub_title = $payload['sub_title']; + $this->sub_title = $payload['sub_title'] ?? null; $this->title = $payload['title']; - $this->year = $payload['year']; + $this->year = $payload['year'] ?? null; } /** @@ -143,7 +143,7 @@ final class ProgramEntity { * @throws \RuntimeException */ public static function create(array $payload): ProgramEntity { - if (!is_array($payload['categories'])) { + if (isset($payload['categories']) && !is_array($payload['categories'])) { throw new RuntimeException('blah-blah-blah'); } @@ -151,11 +151,11 @@ final class ProgramEntity { throw new RuntimeException('blah-blah-blah'); } - if (!is_array($payload['countries'])) { + if (isset($payload['countries']) && !is_array($payload['countries'])) { throw new RuntimeException('blah-blah-blah'); } - if (!is_array($payload['credits'])) { + if (isset($payload['credits']) && !is_array($payload['credits'])) { throw new RuntimeException('blah-blah-blah'); } @@ -163,19 +163,19 @@ final class ProgramEntity { throw new RuntimeException('blah-blah-blah'); } - if (!is_string($payload['description'])) { + if (isset($payload['description']) && !is_string($payload['description'])) { throw new RuntimeException('blah-blah-blah'); } - if (!is_array($payload['icons'])) { + if (isset($payload['icons']) && !is_array($payload['icons'])) { throw new RuntimeException('blah-blah-blah'); } - if (!is_string($payload['parents_guide'])) { + if (isset($payload['parents_guide']) && !is_string($payload['parents_guide'])) { throw new RuntimeException('blah-blah-blah'); } - if (!is_array($payload['productions'])) { + if (isset($payload['productions']) && !is_array($payload['productions'])) { throw new RuntimeException('blah-blah-blah'); } @@ -187,7 +187,7 @@ final class ProgramEntity { throw new RuntimeException('blah-blah-blah'); } - if (!is_string($payload['sub_title'])) { + if (isset($payload['sub_title']) && !is_string($payload['sub_title'])) { throw new RuntimeException('blah-blah-blah'); } @@ -195,7 +195,7 @@ final class ProgramEntity { throw new RuntimeException('blah-blah-blah'); } - if (!is_string($payload['year'])) { + if (isset($payload['year']) && !is_string($payload['year'])) { throw new RuntimeException('blah-blah-blah'); } -- cgit v1.2.3 From 92bfdcb284477b66d0b3770bc8fbaf1c12cc0b56 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 15:42:53 +0400 Subject: Updated channel repository Signed-off-by: Valentin Popov --- src/Repositories/ChannelRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repositories/ChannelRepository.php b/src/Repositories/ChannelRepository.php index 4a400f2..44eac36 100644 --- a/src/Repositories/ChannelRepository.php +++ b/src/Repositories/ChannelRepository.php @@ -62,7 +62,7 @@ final class ChannelRepository implements BaseRepository { } /** - * @return array + * @return \EPGService\Entities\ChannelEntity[] * * @throws \GuzzleHttp\Exception\GuzzleException * @throws \RuntimeException -- cgit v1.2.3 From a52e2e198708cf3e24eda73cbbc5906593cc730a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 15:49:06 +0400 Subject: Added DateTime of channel entity Signed-off-by: Valentin Popov --- src/Entities/ChannelEntity.php | 29 ++++++++++++++-------------- src/Repositories/ChannelRepository.php | 6 +++++- tests/Repositories/ChannelRepositoryTest.php | 3 ++- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/Entities/ChannelEntity.php b/src/Entities/ChannelEntity.php index 0d8d3fc..4881722 100644 --- a/src/Entities/ChannelEntity.php +++ b/src/Entities/ChannelEntity.php @@ -19,21 +19,22 @@ declare(strict_types = 1); namespace EPGService\Entities; +use DateTime; use RuntimeException; use function is_string; /** - * @property-read string $base_id - * @property-read string $base_name - * @property-read string $epg_id - * @property-read string $geo_data - * @property-read string $href - * @property-read string $icon - * @property-read string $id - * @property-read string $lang - * @property-read string $name - * @property-read string $update_at - * @property-read string $week + * @property-read string $base_id + * @property-read string $base_name + * @property-read string $epg_id + * @property-read string $geo_data + * @property-read string $href + * @property-read string $icon + * @property-read string $id + * @property-read string $lang + * @property-read string $name + * @property-read \DateTime $update_at + * @property-read string $week * * @copyright Copyright © 2020 “Valentin Popov” * @license http://www.apache.org/licenses/LICENSE-2.0 @@ -86,9 +87,9 @@ final class ChannelEntity { private string $name; /** - * @var string + * @var \DateTime */ - private string $update_at; + private DateTime $update_at; /** * @var string @@ -156,7 +157,7 @@ final class ChannelEntity { throw new RuntimeException('blah-blah-blah'); } - if (!is_string($payload['update_at'])) { + if (!$payload['update_at'] instanceof DateTime) { throw new RuntimeException('blah-blah-blah'); } diff --git a/src/Repositories/ChannelRepository.php b/src/Repositories/ChannelRepository.php index 44eac36..772e4f9 100644 --- a/src/Repositories/ChannelRepository.php +++ b/src/Repositories/ChannelRepository.php @@ -19,6 +19,7 @@ declare(strict_types = 1); namespace EPGService\Repositories; +use DateTime; use EPGService\Entities\ChannelEntity; use EPGService\Environments\ServiceEnvironment; use EPGService\Parsers\StringParser; @@ -66,6 +67,7 @@ final class ChannelRepository implements BaseRepository { * * @throws \GuzzleHttp\Exception\GuzzleException * @throws \RuntimeException + * @throws \Exception */ public function get(): array { $response = $this->client->get(self::METHOD); @@ -84,6 +86,8 @@ final class ChannelRepository implements BaseRepository { continue; } + $update = StringParser::get($element->update); + $result[] = ChannelEntity::create([ 'base_id' => StringParser::get($element->{'base-channel'}), 'base_name' => StringParser::get($element->{'base-channel'}['id']), @@ -94,7 +98,7 @@ final class ChannelRepository implements BaseRepository { 'id' => StringParser::get($element['id']), 'lang' => StringParser::get($element->{'display-name'}['lang']), 'name' => StringParser::get($element->{'base-channel'}), - 'update_at' => StringParser::get($element->update), + 'update_at' => new DateTime($update), 'week' => StringParser::get($element->week), ]); } diff --git a/tests/Repositories/ChannelRepositoryTest.php b/tests/Repositories/ChannelRepositoryTest.php index 2843a8b..eea6511 100644 --- a/tests/Repositories/ChannelRepositoryTest.php +++ b/tests/Repositories/ChannelRepositoryTest.php @@ -19,6 +19,7 @@ declare(strict_types = 1); namespace Tests\Repositories; +use DateTime; use EPGService\Repositories\ChannelRepository; use PHPUnit\Framework\TestCase; use Tests\Utilities\GetServiceEnvironment; @@ -44,8 +45,8 @@ final class ChannelRepositoryTest extends TestCase { self::assertIsString($channel->id); self::assertIsString($channel->lang); self::assertIsString($channel->name); - self::assertIsString($channel->update_at); self::assertIsString($channel->week); + self::isInstanceOf(DateTime::class, $channel->update_at); } } } -- cgit v1.2.3 From 131be3511360ba4083caf72d40c47d3f6d5c473f Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 16:00:14 +0400 Subject: Added week of program Signed-off-by: Valentin Popov --- src/Repositories/ProgramRepository.php | 22 ++++++++++++++++++---- tests/Repositories/ProgramRepositoryTest.php | 3 ++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Repositories/ProgramRepository.php b/src/Repositories/ProgramRepository.php index 494b957..56884da 100644 --- a/src/Repositories/ProgramRepository.php +++ b/src/Repositories/ProgramRepository.php @@ -24,6 +24,7 @@ use EPGService\Entities\Program\CreditEntity; use EPGService\Entities\ProgramEntity; use EPGService\Environments\ServiceEnvironment; use GuzzleHttp\Client; +use GuzzleHttp\RequestOptions; use RuntimeException; use function is_array; @@ -48,12 +49,19 @@ final class ProgramRepository implements BaseRepository { */ private Client $client; + /** + * @var string + */ + private string $week; + /** * @param \EPGService\Environments\ServiceEnvironment $environment * @param string $channel_id + * @param string $week */ - private function __construct(ServiceEnvironment $environment, string $channel_id) { + private function __construct(ServiceEnvironment $environment, string $channel_id, string $week) { $this->channel_id = $channel_id; + $this->week = $week; $this->client = new Client([ 'base_uri' => $environment->getUrl(), @@ -63,11 +71,12 @@ final class ProgramRepository implements BaseRepository { /** * @param \EPGService\Environments\ServiceEnvironment $environment * @param string $channel_id + * @param string $week * * @return \EPGService\Repositories\ProgramRepository */ - public static function create(ServiceEnvironment $environment, string $channel_id): ProgramRepository { - return new ProgramRepository($environment, $channel_id); + public static function create(ServiceEnvironment $environment, string $channel_id, string $week): ProgramRepository { + return new ProgramRepository($environment, $channel_id, $week); } /** @@ -156,7 +165,12 @@ final class ProgramRepository implements BaseRepository { */ public function get(): array { $uri = sprintf(self::METHOD, $this->channel_id); - $response = $this->client->get($uri); + + $response = $this->client->get($uri, [ + RequestOptions::QUERY => [ + 'week' => $this->week, + ], + ]); $content = $response->getBody()->getContents(); $json = json_decode($content, true, 512, JSON_THROW_ON_ERROR); diff --git a/tests/Repositories/ProgramRepositoryTest.php b/tests/Repositories/ProgramRepositoryTest.php index f8a32d7..f943bb6 100644 --- a/tests/Repositories/ProgramRepositoryTest.php +++ b/tests/Repositories/ProgramRepositoryTest.php @@ -36,11 +36,12 @@ final class ProgramRepositoryTest extends TestCase { * @throws \Exception */ public function testGetAction(): void { + $week = date('Y-m-d', strtotime('this week')); $env = GetServiceEnvironment::get(); $channels = ChannelRepository::create($env)->get(); $channel = array_shift($channels); - foreach (ProgramRepository::create($env, $channel->id)->get() as $program) { + foreach (ProgramRepository::create($env, $channel->id, $week)->get() as $program) { /** @var \EPGService\Entities\ProgramEntity $program */ self::assertNotEmpty($program->channel_id); -- cgit v1.2.3 From b95c97fc07bee5c4bcb5d582d8aff9991922aaa1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 16:04:57 +0400 Subject: Added presenter Signed-off-by: Valentin Popov --- src/Presenter/ServicePresenter.php | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/Presenter/ServicePresenter.php diff --git a/src/Presenter/ServicePresenter.php b/src/Presenter/ServicePresenter.php new file mode 100644 index 0000000..f5b1e61 --- /dev/null +++ b/src/Presenter/ServicePresenter.php @@ -0,0 +1,92 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Presenter + */ +final class ServicePresenter { + /** + * @var \EPGService\Environments\ServiceEnvironment + */ + private ServiceEnvironment$environment; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + */ + private function __construct(ServiceEnvironment $environment) { + $this->environment = $environment; + } + + /** + * @return \EPGService\Entities\CategoryEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getCategories(): array { + return CategoryRepository::create($this->environment)->get(); + } + + /** + * @return \EPGService\Entities\ChannelEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getChannels(): array { + return ChannelRepository::create($this->environment)->get(); + } + + /** + * @return \EPGService\Entities\GenreEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getGenres(): array { + return GenreRepository::create($this->environment)->get(); + } + + /** + * @param string $channel_id + * @param string $week + * + * @return \EPGService\Entities\ProgramEntity[] + * + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ + public function getPrograms(string $channel_id, string $week): array { + return ProgramRepository::create($this->environment, $channel_id, $week)->get(); + } +} -- cgit v1.2.3 From c7bd59904658c3f3a451dd12f36dcabae161c04d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 16:08:00 +0400 Subject: Updated PhpDoc Signed-off-by: Valentin Popov --- tests/Repositories/CategoryRepositoryTest.php | 2 ++ tests/Repositories/ChannelRepositoryTest.php | 5 +++++ tests/Repositories/GenreRepositoryTest.php | 2 ++ 3 files changed, 9 insertions(+) diff --git a/tests/Repositories/CategoryRepositoryTest.php b/tests/Repositories/CategoryRepositoryTest.php index f78f5b4..25dbdd8 100644 --- a/tests/Repositories/CategoryRepositoryTest.php +++ b/tests/Repositories/CategoryRepositoryTest.php @@ -31,6 +31,8 @@ use Tests\Utilities\GetServiceEnvironment; final class CategoryRepositoryTest extends TestCase { /** * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception */ public function testGetAction(): void { $env = GetServiceEnvironment::get(); diff --git a/tests/Repositories/ChannelRepositoryTest.php b/tests/Repositories/ChannelRepositoryTest.php index eea6511..b9d9116 100644 --- a/tests/Repositories/ChannelRepositoryTest.php +++ b/tests/Repositories/ChannelRepositoryTest.php @@ -30,6 +30,11 @@ use Tests\Utilities\GetServiceEnvironment; * @package Tests\Repositories */ final class ChannelRepositoryTest extends TestCase { + /** + * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception + */ public function testGetAction(): void { $env = GetServiceEnvironment::get(); diff --git a/tests/Repositories/GenreRepositoryTest.php b/tests/Repositories/GenreRepositoryTest.php index 1598bbd..8afe351 100644 --- a/tests/Repositories/GenreRepositoryTest.php +++ b/tests/Repositories/GenreRepositoryTest.php @@ -31,6 +31,8 @@ use Tests\Utilities\GetServiceEnvironment; final class GenreRepositoryTest extends TestCase { /** * @throws \GuzzleHttp\Exception\GuzzleException + * @throws \RuntimeException + * @throws \Exception */ public function testGetAction(): void { $env = GetServiceEnvironment::get(); -- cgit v1.2.3 From fb31785d9b6eaaef5b3bcdf09c9dfaf5b7eb01d0 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 16:11:18 +0400 Subject: Updated composer dependency Signed-off-by: Valentin Popov --- composer.json | 16 +- composer.lock | 2565 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2580 insertions(+), 1 deletion(-) create mode 100644 composer.lock diff --git a/composer.json b/composer.json index 1260768..f292995 100644 --- a/composer.json +++ b/composer.json @@ -10,5 +10,19 @@ } ], "minimum-stability": "alpha", - "require": {} + "autoload": { + "psr-4": { + "EPGService\\": "src/", + "Tests\\": "tests/" + } + }, + "require": { + "guzzlehttp/guzzle": "^7.0", + "ext-SimpleXML": "^7.4" + }, + "require-dev": { + "phpunit/phpunit": "^9.2", + "fzaninotto/faker": "^1.9", + "vlucas/phpdotenv": "^5.1" + } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..0fd47d7 --- /dev/null +++ b/composer.lock @@ -0,0 +1,2565 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "740aecc5e2319aaf77d3b09e7feae5d4", + "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "7.0.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/2d9d3c186a6637a43193e66b097c50e4451eaab2", + "reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.6.1", + "php": "^7.2.5", + "psr/http-client": "^1.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.0", + "ext-curl": "*", + "php-http/client-integration-tests": "dev-phpunit8", + "phpunit/phpunit": "^8.5.5", + "psr/log": "^1.1" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "time": "2020-06-27T10:33:25+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2019-07-01T23:21:34+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + } + ], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-05-29T17:27:14+00:00" + }, + { + "name": "fzaninotto/faker", + "version": "v1.9.1", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", + "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "ext-intl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7", + "squizlabs/php_codesniffer": "^2.9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2019-12-12T13:22:17+00:00" + }, + { + "name": "graham-campbell/result-type", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/7e279d2cd5d7fbb156ce46daada972355cea27bb", + "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0", + "phpoption/phpoption": "^1.7.3" + }, + "require-dev": { + "phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2020-04-13T13:17:36+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.10.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-06-29T13:22:24+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "shasum": "" + }, + "require": { + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" + }, + "require-dev": { + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2020-02-22T12:28:44+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2020-06-27T10:12:23+00:00" + }, + { + "name": "phpoption/phpoption", + "version": "1.7.4", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "shasum": "" + }, + "require": { + "php": "^5.5.9 || ^7.0 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.3", + "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2020-06-07T10:40:07+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160", + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2", + "php": "^7.2", + "phpdocumentor/reflection-docblock": "^5.0", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" + }, + "require-dev": { + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2020-07-08T12:44:21+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "8.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca6647ffddd2add025ab3f21644a441d7c146cdc", + "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.3", + "phpunit/php-file-iterator": "^3.0", + "phpunit/php-text-template": "^2.0", + "phpunit/php-token-stream": "^4.0", + "sebastian/code-unit-reverse-lookup": "^2.0", + "sebastian/environment": "^5.0", + "sebastian/version": "^3.0", + "theseer/tokenizer": "^1.1.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "8.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-05-23T08:02:54+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/25fefc5b19835ca653877fe081644a3f8c1d915e", + "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-11T05:18:21+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "f6eedfed1085dd1f4c599629459a0277d25f9a66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f6eedfed1085dd1f4c599629459a0277d25f9a66", + "reference": "f6eedfed1085dd1f4c599629459a0277d25f9a66", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T11:53:53+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/6ff9c8ea4d3212b88fcf74e25e516e2c51c99324", + "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T11:55:37+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/cc49734779cbb302bf51a44297dab8c4bbf941e7", + "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T11:58:13+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "4.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "5672711b6b07b14d5ab694e700c62eeb82fcf374" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5672711b6b07b14d5ab694e700c62eeb82fcf374", + "reference": "5672711b6b07b14d5ab694e700c62eeb82fcf374", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-27T06:36:25+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.2.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "1c6a9e4312e209e659f1fce3ce88dd197c2448f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1c6a9e4312e209e659f1fce3ce88dd197c2448f6", + "reference": "1c6a9e4312e209e659f1fce3ce88dd197c2448f6", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.5", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.3", + "phpspec/prophecy": "^1.10.3", + "phpunit/php-code-coverage": "^8.0.2", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-invoker": "^3.0.2", + "phpunit/php-text-template": "^2.0.2", + "phpunit/php-timer": "^5.0.1", + "sebastian/code-unit": "^1.0.5", + "sebastian/comparator": "^4.0.3", + "sebastian/diff": "^4.0.1", + "sebastian/environment": "^5.1.2", + "sebastian/exporter": "^4.0.2", + "sebastian/global-state": "^4.0", + "sebastian/object-enumerator": "^4.0.2", + "sebastian/resource-operations": "^3.0.2", + "sebastian/type": "^2.1.1", + "sebastian/version": "^3.0.1" + }, + "require-dev": { + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "funding": [ + { + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-13T17:55:55+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "c1e2df332c905079980b119c4db103117e5e5c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/c1e2df332c905079980b119c4db103117e5e5c90", + "reference": "c1e2df332c905079980b119c4db103117e5e5c90", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:50:45+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ee51f9bb0c6d8a43337055db3120829fa14da819", + "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:04:00+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f", + "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:05:46+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113", + "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-30T04:46:02+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2", + "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:07:24+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "571d721db4aec847a0e59690b954af33ebf9f023" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/571d721db4aec847a0e59690b954af33ebf9f023", + "reference": "571d721db4aec847a0e59690b954af33ebf9f023", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:08:55+00:00" + }, + { + "name": "sebastian/global-state", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "shasum": "" + }, + "require": { + "php": "^7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2020-02-07T06:11:37+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/074fed2d0a6d08e1677dd8ce9d32aecb384917b8", + "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:11:32+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "127a46f6b057441b201253526f81d5406d6c7840" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/127a46f6b057441b201253526f81d5406d6c7840", + "reference": "127a46f6b057441b201253526f81d5406d6c7840", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:12:55+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/062231bf61d2b9448c4fa5a7643b5e1829c11d63", + "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:14:17+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0653718a5a629b065e91f774595267f8dc32e213" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0653718a5a629b065e91f774595267f8dc32e213", + "reference": "0653718a5a629b065e91f774595267f8dc32e213", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:16:22+00:00" + }, + { + "name": "sebastian/type", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/86991e2b33446cd96e648c18bcdb1e95afb2c05a", + "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-05T08:31:53+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "626586115d0ed31cb71483be55beb759b5af5a3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/626586115d0ed31cb71483be55beb759b5af5a3c", + "reference": "626586115d0ed31cb71483be55beb759b5af5a3c", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:18:43+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "75a63c33a8577608444246075ea0af0d052e452a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", + "reference": "75a63c33a8577608444246075ea0af0d052e452a", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2020-07-12T23:59:07+00:00" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.1.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "448c76d7a9e30c341ff5bc367a923af74ae18467" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/448c76d7a9e30c341ff5bc367a923af74ae18467", + "reference": "448c76d7a9e30c341ff5bc367a923af74ae18467", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-filter": "*", + "phpunit/phpunit": "^7.5.20 || ^8.5.2 || ^9.0" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://vancelucas.com/" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2020-07-14T19:26:25+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^7.5.13" + }, + "type": "library", + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2020-07-08T17:02:28+00:00" + } + ], + "aliases": [], + "minimum-stability": "alpha", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "ext-simplexml": "^7.4" + }, + "platform-dev": [], + "plugin-api-version": "1.1.0" +} -- cgit v1.2.3 From 712baf438af0d1792a667866d65aa5f61e5fb9e1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 16:12:30 +0400 Subject: Added environment file Signed-off-by: Valentin Popov --- .env.example | 1 + .gitignore | 1 + 2 files changed, 2 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5d0b26c --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +EPG_SERVICE_KEY= diff --git a/.gitignore b/.gitignore index 843e828..c01293d 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,7 @@ Temporary Items # PHPUnit /app/phpunit.xml /phpunit.xml +/.env # Build data /build/ -- cgit v1.2.3 From 741886916b2ae0eb449851c1511e3820b9b05baf Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 17:01:06 +0400 Subject: Added example of get genres Signed-off-by: Valentin Popov --- examples/get-genres.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/get-genres.php diff --git a/examples/get-genres.php b/examples/get-genres.php new file mode 100644 index 0000000..2bfe576 --- /dev/null +++ b/examples/get-genres.php @@ -0,0 +1,33 @@ +getGenres(); + +# Or using repository +$repository = GenreRepository::create($environment); +$genres = $repository->get(); -- cgit v1.2.3 From 383a120c0103a7bfb459bf8fa2800691a355c4f0 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 17:03:07 +0400 Subject: Added example of get categories Signed-off-by: Valentin Popov --- examples/get-categories.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/get-categories.php diff --git a/examples/get-categories.php b/examples/get-categories.php new file mode 100644 index 0000000..a6a24af --- /dev/null +++ b/examples/get-categories.php @@ -0,0 +1,33 @@ +getCategories(); + +# Or using repository +$repository = CategoryRepository::create($environment); +$categories = $repository->get(); -- cgit v1.2.3 From b0fc7d5ff860f383bc2e690e2f13bdc838ddb863 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 17:04:51 +0400 Subject: Added example of get channels Signed-off-by: Valentin Popov --- examples/get-channels.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/get-channels.php diff --git a/examples/get-channels.php b/examples/get-channels.php new file mode 100644 index 0000000..645eb96 --- /dev/null +++ b/examples/get-channels.php @@ -0,0 +1,33 @@ +getChannels(); + +# Or using repository +$repository = ChannelRepository::create($environment); +$channels = $repository->get(); -- cgit v1.2.3 From b10e4aa662d486b26166a1b409945376cb8a79c4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 17:08:55 +0400 Subject: Added example of get programs Signed-off-by: Valentin Popov --- examples/get-programs.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/get-programs.php diff --git a/examples/get-programs.php b/examples/get-programs.php new file mode 100644 index 0000000..9dbe581 --- /dev/null +++ b/examples/get-programs.php @@ -0,0 +1,38 @@ +getChannels(); +$channel = array_shift($channels); + +# Using presenter +$presenter = ServicePresenter::create($environment); +$current_week = date('Y-m-d', strtotime('this week')); +$programs = $presenter->getPrograms($channel->id, $current_week); + +# Or using repository +$current_week = date('Y-m-d', strtotime('this week')); +$repository = ProgramRepository::create($environment, $channel->id, $current_week); +$programs = $repository->get(); -- cgit v1.2.3 From bf538eac242e4fc2962e626bfb722fa0638afcb2 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2020 17:09:12 +0400 Subject: Added create static function Signed-off-by: Valentin Popov --- src/Presenter/ServicePresenter.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Presenter/ServicePresenter.php b/src/Presenter/ServicePresenter.php index f5b1e61..e3117ed 100644 --- a/src/Presenter/ServicePresenter.php +++ b/src/Presenter/ServicePresenter.php @@ -43,6 +43,15 @@ final class ServicePresenter { $this->environment = $environment; } + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * + * @return \EPGService\Presenter\ServicePresenter + */ + public static function create(ServiceEnvironment $environment): ServicePresenter { + return new ServicePresenter($environment); + } + /** * @return \EPGService\Entities\CategoryEntity[] * -- cgit v1.2.3 From 5ba704abceb11f6e0bb3646492809a323a8fa19d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 19 Jul 2020 19:16:47 +0400 Subject: Added country entity Signed-off-by: Valentin Popov --- src/Entities/CountryEntity.php | 123 +++++++++++++++++++++++++++++++++++ tests/Entities/CountryEntityTest.php | 49 ++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 src/Entities/CountryEntity.php create mode 100644 tests/Entities/CountryEntityTest.php diff --git a/src/Entities/CountryEntity.php b/src/Entities/CountryEntity.php new file mode 100644 index 0000000..fb559d8 --- /dev/null +++ b/src/Entities/CountryEntity.php @@ -0,0 +1,123 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Entities + */ +final class CountryEntity { + /** + * @var int + */ + private int $id; + + /** + * @var string + */ + private string $iso; + + /** + * @var string + */ + private string $lang; + + /** + * @var string + */ + private string $name; + + /** + * @var string + */ + private string $version; + + /** + * @param array $payload + */ + private function __construct(array $payload) { + $this->id = $payload['id']; + $this->iso = $payload['iso']; + $this->lang = $payload['lang']; + $this->name = $payload['name']; + $this->version = $payload['version']; + } + + /** + * @param array $payload + * + * @return \EPGService\Entities\CountryEntity + * + * @throws \RuntimeException + */ + public static function create(array $payload): CountryEntity { + if (!is_int($payload['id'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['iso'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['lang'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['name'])) { + throw new RuntimeException('blah-blah-blah'); + } + + if (!is_string($payload['version'])) { + throw new RuntimeException('blah-blah-blah'); + } + + return new CountryEntity($payload); + } + + /** + * @param string $name + * + * @return mixed + */ + public function __get(string $name) { + return $this->$name; + } + + /** + * @param string $name + * @param mixed $value + * + * @throws \RuntimeException + */ + public function __set(string $name, $value) { + throw new RuntimeException('blah-blah-blah'); + } +} diff --git a/tests/Entities/CountryEntityTest.php b/tests/Entities/CountryEntityTest.php new file mode 100644 index 0000000..dd44075 --- /dev/null +++ b/tests/Entities/CountryEntityTest.php @@ -0,0 +1,49 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Entities + */ +final class CountryEntityTest extends TestCase { + public function testCreateEntity(): void { + $faker = Faker::create(); + + $id = $faker->numberBetween(1, 100); + $iso = $faker->countryCode; + $lang = $faker->languageCode; + $name = $faker->unique()->sha256; + $version = $faker->unique()->sha256; + + $entity = CountryEntity::create(compact('id', 'iso', 'lang', 'name', 'version')); + + self::assertEquals($id, $entity->id); + self::assertEquals($iso, $entity->iso); + self::assertEquals($lang, $entity->lang); + self::assertEquals($name, $entity->name); + self::assertEquals($version, $entity->version); + } +} -- cgit v1.2.3 From 915cd7b1e0f0f1f994fddafdacfea8f649ff2fa9 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 19 Jul 2020 19:47:38 +0400 Subject: Added country repository Signed-off-by: Valentin Popov --- src/Repositories/CountryRepository.php | 92 ++++++++++++++++++++++++++++ tests/Repositories/CountryRepositoryTest.php | 44 +++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 src/Repositories/CountryRepository.php create mode 100644 tests/Repositories/CountryRepositoryTest.php diff --git a/src/Repositories/CountryRepository.php b/src/Repositories/CountryRepository.php new file mode 100644 index 0000000..cb7e3ae --- /dev/null +++ b/src/Repositories/CountryRepository.php @@ -0,0 +1,92 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package EPGService\Repositories + */ +final class CountryRepository implements BaseRepository { + /** + * @var string + */ + private const METHOD = 'country_list'; + + /** + * @var \GuzzleHttp\Client + */ + private Client $client; + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + */ + private function __construct(ServiceEnvironment $environment) { + $this->client = new Client([ + 'base_uri' => $environment->getUrl(), + ]); + } + + /** + * @param \EPGService\Environments\ServiceEnvironment $environment + * + * @return \EPGService\Repositories\CountryRepository + */ + public static function create(ServiceEnvironment $environment): CountryRepository { + return new CountryRepository($environment); + } + + public function get(): array { + $response = $this->client->get(self::METHOD); + $content = $response->getBody()->getContents(); + $xml = simplexml_load_string($content); + + if (is_bool($xml) || !$xml->element instanceof SimpleXMLElement) { + throw new RuntimeException('blah-blah-blah'); + } + + $result = []; + + foreach ($xml->element as $element) { + if (!$element instanceof SimpleXMLElement) { + trigger_error('blah-blah-blah', E_USER_WARNING); + continue; + } + + $result[] = CountryEntity::create([ + 'id' => StringParser::get($element['id']), + 'iso' => StringParser::get($element['ISO']), + 'lang' => StringParser::get($element->name['lang']), + 'name' => StringParser::get($element->name), + 'version' => StringParser::get($element['version']), + ]); + } + + return $result; + } +} diff --git a/tests/Repositories/CountryRepositoryTest.php b/tests/Repositories/CountryRepositoryTest.php new file mode 100644 index 0000000..160e388 --- /dev/null +++ b/tests/Repositories/CountryRepositoryTest.php @@ -0,0 +1,44 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 + * @package Tests\Repositories + */ +final class CountryRepositoryTest extends TestCase { + public function testActionGet(): void { + $env = GetServiceEnvironment::get(); + + foreach (CountryRepository::create($env)->get() as $country) { + /** @var \EPGService\Entities\CountryEntity $country */ + self::assertNotEmpty($country->id); + self::assertNotEmpty($country->iso); + self::assertNotEmpty($country->lang); + self::assertNotEmpty($country->name); + self::assertNotEmpty($country->version); + } + } +} -- cgit v1.2.3 From 400862f5eea453730b556b34faf1bb45b03a6751 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 19 Jul 2020 19:48:41 +0400 Subject: Updated country entity Signed-off-by: Valentin Popov --- src/Entities/CountryEntity.php | 7 +++---- tests/Entities/CountryEntityTest.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Entities/CountryEntity.php b/src/Entities/CountryEntity.php index fb559d8..37d4d6e 100644 --- a/src/Entities/CountryEntity.php +++ b/src/Entities/CountryEntity.php @@ -20,7 +20,6 @@ declare(strict_types = 1); namespace EPGService\Entities; use RuntimeException; -use function is_int; use function is_string; /** @@ -36,9 +35,9 @@ use function is_string; */ final class CountryEntity { /** - * @var int + * @var string */ - private int $id; + private string $id; /** * @var string @@ -79,7 +78,7 @@ final class CountryEntity { * @throws \RuntimeException */ public static function create(array $payload): CountryEntity { - if (!is_int($payload['id'])) { + if (!is_string($payload['id'])) { throw new RuntimeException('blah-blah-blah'); } diff --git a/tests/Entities/CountryEntityTest.php b/tests/Entities/CountryEntityTest.php index dd44075..ffff4fd 100644 --- a/tests/Entities/CountryEntityTest.php +++ b/tests/Entities/CountryEntityTest.php @@ -32,7 +32,7 @@ final class CountryEntityTest extends TestCase { public function testCreateEntity(): void { $faker = Faker::create(); - $id = $faker->numberBetween(1, 100); + $id = $faker->unique()->sha256; $iso = $faker->countryCode; $lang = $faker->languageCode; $name = $faker->unique()->sha256; -- cgit v1.2.3 From 7d078315d6f592de968fbaf9959a2dbc2f59ddfe Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 19 Jul 2020 20:14:20 +0400 Subject: Updated genre entity Signed-off-by: Valentin Popov --- src/Entities/GenreEntity.php | 26 +++++++++++--------------- 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')); -- cgit v1.2.3 From a5a69a7732eaf278200ff2af53ed875de43714af Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 19 Jul 2020 20:15:07 +0400 Subject: Fixed PhpDoc Signed-off-by: Valentin Popov --- src/Entities/CountryEntity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/CountryEntity.php b/src/Entities/CountryEntity.php index 37d4d6e..bf8b6f7 100644 --- a/src/Entities/CountryEntity.php +++ b/src/Entities/CountryEntity.php @@ -23,7 +23,7 @@ use RuntimeException; use function is_string; /** - * @property-read int $id + * @property-read string $id * @property-read string $iso * @property-read string $lang * @property-read string $name -- cgit v1.2.3 From 506e16bdfcae6996adacdcb5ba23fdf45c98bafe Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 19 Jul 2020 20:18:09 +0400 Subject: Updated category entity Signed-off-by: Valentin Popov --- src/Entities/CategoryEntity.php | 26 +++++++++++--------------- tests/Entities/CategoryEntityTest.php | 8 ++++---- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/Entities/CategoryEntity.php b/src/Entities/CategoryEntity.php index af44434..2d113a4 100644 --- a/src/Entities/CategoryEntity.php +++ b/src/Entities/CategoryEntity.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 CategoryEntity { /** - * @var int + * @var string */ - private int $id; + private string $id; /** * @var string @@ -55,16 +54,13 @@ final class CategoryEntity { 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']; } /** @@ -74,7 +70,7 @@ final class CategoryEntity { * @throws \RuntimeException */ public static function create(array $payload): CategoryEntity { - if (!is_int($payload['id'])) { + if (!is_string($payload['id'])) { throw new RuntimeException('blah-blah-blah'); } @@ -90,7 +86,7 @@ final class CategoryEntity { throw new RuntimeException('blah-blah-blah'); } - return new CategoryEntity($payload['id'], $payload['lang'], $payload['name'], $payload['version']); + return new CategoryEntity($payload); } /** diff --git a/tests/Entities/CategoryEntityTest.php b/tests/Entities/CategoryEntityTest.php index 6ad7bd3..35363fa 100644 --- a/tests/Entities/CategoryEntityTest.php +++ b/tests/Entities/CategoryEntityTest.php @@ -32,10 +32,10 @@ final class CategoryEntityTest 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 = CategoryEntity::create(compact('id', 'lang', 'name', 'version')); -- cgit v1.2.3