From 45ea324f12a598f632ab497cc0c363f37b79fd7b Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Wed, 2 Nov 2022 17:13:56 +0100 Subject: [PATCH 1/8] chore(API-1925): Add rector dev dependency --- Makefile | 4 ++ composer.json | 3 +- composer.lock | 181 +++++++++++++++++++++++++++++++++++++++++--------- rector.php | 28 ++++++++ 4 files changed, 183 insertions(+), 33 deletions(-) create mode 100644 rector.php diff --git a/Makefile b/Makefile index 821e5690..07457e32 100644 --- a/Makefile +++ b/Makefile @@ -37,3 +37,7 @@ cs: ## Run code style check .PHONY: fix-cs fix-cs: ## Fix PHP code style $(DOCKER_RUN) bin/php-cs-fixer fix --config=.php_cs.php + +.PHONY: rector +rector: ## Run rector + $(DOCKER_RUN) bin/rector diff --git a/composer.json b/composer.json index fb870e9a..b98c6792 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "symfony/yaml": "^4.2", "donatj/mock-webserver": "^2.0", "http-interop/http-factory-guzzle": "^1.0", - "php-http/guzzle6-adapter": "^2.0" + "php-http/guzzle6-adapter": "^2.0", + "rector/rector": "^0.14.6" }, "config": { "bin-dir": "bin", diff --git a/composer.lock b/composer.lock index 38198866..d98feb32 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b8f1aa13a098971e273ffb1db83eabd1", + "content-hash": "613cec11031c9294e97d7159f27e06c4", "packages": [ { "name": "guzzlehttp/psr7", @@ -2417,6 +2417,65 @@ }, "time": "2021-12-08T12:19:24+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.8.11", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "46e223dd68a620da18855c23046ddb00940b4014" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014", + "reference": "46e223dd68a620da18855c23046ddb00940b4014", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.8.11" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-10-24T15:45:13+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "7.0.15", @@ -2716,16 +2775,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.30", + "version": "8.5.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4fd448df9affda65a5faa58f8b93087d415216ce" + "reference": "33c126b09a42de5c99e5e8032b54e8221264a74e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4fd448df9affda65a5faa58f8b93087d415216ce", - "reference": "4fd448df9affda65a5faa58f8b93087d415216ce", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/33c126b09a42de5c99e5e8032b54e8221264a74e", + "reference": "33c126b09a42de5c99e5e8032b54e8221264a74e", "shasum": "" }, "require": { @@ -2793,7 +2852,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.30" + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.31" }, "funding": [ { @@ -2809,7 +2868,7 @@ "type": "tidelift" } ], - "time": "2022-09-25T03:43:00+00:00" + "time": "2022-10-28T05:57:37+00:00" }, { "name": "psr/cache", @@ -3008,6 +3067,64 @@ }, "time": "2021-05-03T11:20:27+00:00" }, + { + "name": "rector/rector", + "version": "0.14.6", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "e61574288661334155de6e5f0f45497285abad5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/e61574288661334155de6e5f0f45497285abad5d", + "reference": "e61574288661334155de6e5f0f45497285abad5d", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.8.7" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-laravel": "*", + "rector/rector-php-parser": "*", + "rector/rector-phpoffice": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.14-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.14.6" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2022-10-15T22:58:22+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.2", @@ -3739,16 +3856,16 @@ }, { "name": "symfony/console", - "version": "v5.4.12", + "version": "v5.4.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c072aa8f724c3af64e2c7a96b796a4863d24dba1" + "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c072aa8f724c3af64e2c7a96b796a4863d24dba1", - "reference": "c072aa8f724c3af64e2c7a96b796a4863d24dba1", + "url": "https://api.github.com/repos/symfony/console/zipball/ea59bb0edfaf9f28d18d8791410ee0355f317669", + "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669", "shasum": "" }, "require": { @@ -3818,7 +3935,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.12" + "source": "https://github.com/symfony/console/tree/v5.4.15" }, "funding": [ { @@ -3834,7 +3951,7 @@ "type": "tidelift" } ], - "time": "2022-08-17T13:18:05+00:00" + "time": "2022-10-26T21:41:52+00:00" }, { "name": "symfony/event-dispatcher", @@ -4002,16 +4119,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.4.12", + "version": "v5.4.13", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "2d67c1f9a1937406a9be3171b4b22250c0a11447" + "reference": "ac09569844a9109a5966b9438fc29113ce77cf51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/2d67c1f9a1937406a9be3171b4b22250c0a11447", - "reference": "2d67c1f9a1937406a9be3171b4b22250c0a11447", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51", + "reference": "ac09569844a9109a5966b9438fc29113ce77cf51", "shasum": "" }, "require": { @@ -4046,7 +4163,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.12" + "source": "https://github.com/symfony/filesystem/tree/v5.4.13" }, "funding": [ { @@ -4062,7 +4179,7 @@ "type": "tidelift" } ], - "time": "2022-08-02T13:48:16+00:00" + "time": "2022-09-21T19:53:16+00:00" }, { "name": "symfony/finder", @@ -4846,16 +4963,16 @@ }, { "name": "symfony/stopwatch", - "version": "v5.4.5", + "version": "v5.4.13", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30" + "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", - "reference": "4d04b5c24f3c9a1a168a131f6cbe297155bc0d30", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6df7a3effde34d81717bbef4591e5ffe32226d69", + "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69", "shasum": "" }, "require": { @@ -4888,7 +5005,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.5" + "source": "https://github.com/symfony/stopwatch/tree/v5.4.13" }, "funding": [ { @@ -4904,20 +5021,20 @@ "type": "tidelift" } ], - "time": "2022-02-18T16:06:09+00:00" + "time": "2022-09-28T13:19:49+00:00" }, { "name": "symfony/string", - "version": "v5.4.12", + "version": "v5.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "2fc515e512d721bf31ea76bd02fe23ada4640058" + "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/2fc515e512d721bf31ea76bd02fe23ada4640058", - "reference": "2fc515e512d721bf31ea76bd02fe23ada4640058", + "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", "shasum": "" }, "require": { @@ -4974,7 +5091,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.12" + "source": "https://github.com/symfony/string/tree/v5.4.15" }, "funding": [ { @@ -4990,7 +5107,7 @@ "type": "tidelift" } ], - "time": "2022-08-12T17:03:11+00:00" + "time": "2022-10-05T15:16:54+00:00" }, { "name": "symfony/yaml", @@ -5184,5 +5301,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..7dac39ab --- /dev/null +++ b/rector.php @@ -0,0 +1,28 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + __DIR__ . '/spec' + ]); + + $rectorConfig->skip([ + JsonThrowOnErrorRector::class + ]); + + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + + $rectorConfig->sets([ + SetList::CODE_QUALITY, + LevelSetList::UP_TO_PHP_80 + ]); +}; From d6d5a296c3d2a82217180c868de7ca4478cf5fd4 Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Thu, 3 Nov 2022 10:51:01 +0100 Subject: [PATCH 2/8] chore(API-1925): Upgrade minimum PHP dependency to 8.0 --- Dockerfile | 26 ++++++++++++++------------ Makefile | 5 +++++ composer.json | 4 ++-- composer.lock | 40 ++++++++++++++++++++-------------------- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32bbb2ff..390f52f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,19 +25,21 @@ RUN apt-get update && \ /usr/share/lintian/* /usr/share/locale/* /usr/share/man/* # Install PHP with some extensions -RUN apt-get update && \ +RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \ + sh -c 'echo "deb https://packages.sury.org/php/ bullseye main" > /etc/apt/sources.list.d/php.list' && \ + apt-get update && \ apt-get --no-install-recommends --no-install-suggests --yes --quiet install \ - php7.4-cli \ - php7.4-apcu \ - php7.4-mbstring \ - php7.4-curl \ - php7.4-gd \ - php7.4-imagick \ - php7.4-intl \ - php7.4-bcmath \ - php7.4-xdebug \ - php7.4-xml \ - php7.4-zip && \ + php8.0-cli \ + php8.0-apcu \ + php8.0-mbstring \ + php8.0-curl \ + php8.0-gd \ + php8.0-imagick \ + php8.0-intl \ + php8.0-bcmath \ + php8.0-xdebug \ + php8.0-xml \ + php8.0-zip && \ apt-get clean && apt-get --yes --quiet autoremove --purge && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ /usr/share/doc/* /usr/share/groff/* /usr/share/info/* /usr/share/linda/* \ diff --git a/Makefile b/Makefile index 07457e32..9962f786 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,11 @@ DOCKER_RUN = DOCKER_BUILDKIT=1 docker-compose run php_client help: @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-25s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' +.PHONY: build-image +build-image: ## Build docker image + DOCKER_BUILDKIT=1 docker-compose build + +.PHONY: .PHONY: dependencies dependencies: ## Install composer dependencies cp docker-compose.yml.dist docker-compose.yml diff --git a/composer.json b/composer.json index b98c6792..7ee50a20 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ } }, "require": { - "php": ">=7.4", + "php": ">=8.0", "psr/http-message": "^1.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", @@ -43,7 +43,7 @@ "config": { "bin-dir": "bin", "platform": { - "php": "7.4" + "php": "8.0" } }, "suggest": { diff --git a/composer.lock b/composer.lock index d98feb32..6ccc861b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "613cec11031c9294e97d7159f27e06c4", + "content-hash": "0d6b733646d3909893d6a3b95dda42d7", "packages": [ { "name": "guzzlehttp/psr7", @@ -2872,20 +2872,20 @@ }, { "name": "psr/cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { @@ -2905,7 +2905,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for caching libraries", @@ -2915,9 +2915,9 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/master" + "source": "https://github.com/php-fig/cache/tree/3.0.0" }, - "time": "2016-08-06T20:24:11+00:00" + "time": "2021-02-03T23:26:27+00:00" }, { "name": "psr/container", @@ -3019,30 +3019,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -3063,9 +3063,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/2.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:41:46+00:00" }, { "name": "rector/rector", @@ -5295,11 +5295,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=8.0" }, "platform-dev": [], "platform-overrides": { - "php": "7.4" + "php": "8.0" }, "plugin-api-version": "2.2.0" } From f6f973021423a700aec2a59ca2190b06c4dbc75e Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Thu, 3 Nov 2022 11:32:35 +0100 Subject: [PATCH 3/8] chore(API-1925): Upgrade PHP code style from PSR-2 to PSR-12 --- .php_cs.php | 2 +- src/AkeneoPimClientInterface.php | 4 +- src/Api/AppCatalog/AppCatalogApi.php | 5 +- src/Api/AppCatalog/AppCatalogApiInterface.php | 1 + src/Api/AppCatalog/AppCatalogProductApi.php | 3 +- .../AppCatalogProductApiInterface.php | 1 + src/Api/AssetApi.php | 4 +- src/Api/AssetCategoryApi.php | 4 +- src/Api/AssetManager/AssetApi.php | 4 +- src/Api/AssetManager/AssetAttributeApi.php | 4 +- .../AssetManager/AssetAttributeOptionApi.php | 4 +- src/Api/AssetManager/AssetFamilyApi.php | 4 +- src/Api/AssetManager/AssetMediaFileApi.php | 5 +- .../AssetMediaFileApiInterface.php | 1 + src/Api/AssetReferenceFileApi.php | 6 +- src/Api/AssetTagApi.php | 4 +- src/Api/AssetVariationFileApi.php | 6 +- src/Api/AssociationTypeApi.php | 4 +- src/Api/AttributeApi.php | 4 +- src/Api/AttributeGroupApi.php | 4 +- src/Api/AttributeOptionApi.php | 4 +- src/Api/AuthenticationApi.php | 2 +- src/Api/CategoryApi.php | 4 +- src/Api/ChannelApi.php | 4 +- src/Api/CurrencyApi.php | 4 +- src/Api/FamilyApi.php | 4 +- src/Api/FamilyVariantApi.php | 4 +- src/Api/LocaleApi.php | 4 +- src/Api/MeasureFamilyApi.php | 4 +- src/Api/MeasurementFamilyApi.php | 2 +- src/Api/ProductApi.php | 4 +- src/Api/ProductDraftApi.php | 4 +- src/Api/ProductMediaFileApi.php | 8 +-- src/Api/ProductModelApi.php | 4 +- src/Api/ProductModelDraftApi.php | 4 +- src/Api/ProductUuidApi.php | 5 +- src/Api/ProductUuidApiInterface.php | 1 + src/Api/PublishedProductApi.php | 4 +- src/Api/ReferenceEntityApi.php | 4 +- src/Api/ReferenceEntityAttributeApi.php | 4 +- src/Api/ReferenceEntityAttributeOptionApi.php | 4 +- src/Api/ReferenceEntityMediaFileApi.php | 4 +- src/Api/ReferenceEntityRecordApi.php | 4 +- src/Client/HttpClient.php | 24 ++++---- src/Client/ResourceClientInterface.php | 2 +- src/Pagination/PaginationParameter.php | 6 +- src/Search/Operator.php | 58 +++++++++---------- .../UpsertResourceListResponseFactory.php | 2 +- 48 files changed, 132 insertions(+), 124 deletions(-) diff --git a/.php_cs.php b/.php_cs.php index 00769e5a..e6a6be84 100644 --- a/.php_cs.php +++ b/.php_cs.php @@ -2,7 +2,7 @@ return (new PhpCsFixer\Config()) ->setRules(array( - '@PSR2' => true, + '@PSR12' => true, 'linebreak_after_opening_tag' => true, 'ordered_imports' => true, )) diff --git a/src/AkeneoPimClientInterface.php b/src/AkeneoPimClientInterface.php index 912a51ab..3c3ea2a9 100644 --- a/src/AkeneoPimClientInterface.php +++ b/src/AkeneoPimClientInterface.php @@ -136,9 +136,9 @@ public function getAssetAttributeOptionApi(): AssetAttributeOptionApiInterface; public function getAssetMediaFileApi(): AssetMediaFileApiInterface; - public function getProductUuidApi() : ProductUuidApiInterface; + public function getProductUuidApi(): ProductUuidApiInterface; - public function getProductDraftUuidApi() : ProductDraftUuidApiInterface; + public function getProductDraftUuidApi(): ProductDraftUuidApiInterface; public function getAppCatalogApi(): AppCatalogApiInterface; diff --git a/src/Api/AppCatalog/AppCatalogApi.php b/src/Api/AppCatalog/AppCatalogApi.php index 0f8e7d3d..93da7076 100644 --- a/src/Api/AppCatalog/AppCatalogApi.php +++ b/src/Api/AppCatalog/AppCatalogApi.php @@ -1,4 +1,5 @@ .*)$~'; + public const MEDIA_FILES_URI = 'api/rest/v1/media-files'; + public const MEDIA_FILE_URI = 'api/rest/v1/media-files/%s'; + public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/media-files/%s/download'; + public const MEDIA_FILE_URI_CODE_REGEX = '~/api/rest/v1/media\-files/(?P.*)$~'; /** @var ResourceClientInterface */ protected $resourceClient; diff --git a/src/Api/ProductModelApi.php b/src/Api/ProductModelApi.php index 2b9c80d4..1e03f615 100644 --- a/src/Api/ProductModelApi.php +++ b/src/Api/ProductModelApi.php @@ -18,8 +18,8 @@ */ class ProductModelApi implements ProductModelApiInterface { - const PRODUCT_MODEL_URI = 'api/rest/v1/product-models/%s'; - const PRODUCT_MODELS_URI = 'api/rest/v1/product-models'; + public const PRODUCT_MODEL_URI = 'api/rest/v1/product-models/%s'; + public const PRODUCT_MODELS_URI = 'api/rest/v1/product-models'; /** @var ResourceClientInterface */ protected $resourceClient; diff --git a/src/Api/ProductModelDraftApi.php b/src/Api/ProductModelDraftApi.php index a789074c..65b5de03 100644 --- a/src/Api/ProductModelDraftApi.php +++ b/src/Api/ProductModelDraftApi.php @@ -17,8 +17,8 @@ */ class ProductModelDraftApi implements ProductModelDraftApiInterface { - const PRODUCT_MODEL_DRAFT_URI = '/api/rest/v1/product-models/%s/draft'; - const PRODUCT_MODEL_PROPOSAL_URI = '/api/rest/v1/product-models/%s/proposal'; + public const PRODUCT_MODEL_DRAFT_URI = '/api/rest/v1/product-models/%s/draft'; + public const PRODUCT_MODEL_PROPOSAL_URI = '/api/rest/v1/product-models/%s/proposal'; /** @var ResourceClientInterface */ protected $resourceClient; diff --git a/src/Api/ProductUuidApi.php b/src/Api/ProductUuidApi.php index e542e2aa..9f101f8e 100644 --- a/src/Api/ProductUuidApi.php +++ b/src/Api/ProductUuidApi.php @@ -1,4 +1,5 @@ '; - const GREATER_THAN_OR_EQUAL = '>='; - const LOWER_THAN = '<'; - const LOWER_THAN_OR_EQUAL = '<='; - const IN = 'IN'; - const NOT_IN = 'NOT IN'; - const IN_OR_UNCLASSIFIED = 'IN OR UNCLASSIFIED'; - const IN_CHILDREN = 'IN CHILDREN'; - const NOT_IN_CHILDREN = 'NOT IN CHILDREN'; - const UNCLASSIFIED = 'UNCLASSIFIED'; - const GREATER_THAN_ON_ALL_LOCALES = 'GREATER THAN ON ALL LOCALES'; - const GREATER_OR_EQUALS_THAN_ON_ALL_LOCALES = 'GREATER OR EQUALS THAN ON ALL LOCALES'; - const LOWER_THAN_ON_ALL_LOCALES = 'LOWER THAN ON ALL LOCALES'; - const LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES = 'LOWER OR EQUALS THAN ON ALL LOCALES'; - const IS_EMPTY = 'EMPTY'; - const NOT_EMPTY = 'NOT EMPTY'; - const BETWEEN = 'BETWEEN'; - const NOT_BETWEEN = 'NOT BETWEEN'; - const SINCE_LAST_N_DAYS = 'SINCE LAST N DAYS'; - const STARTS_WITH = 'STARTS WITH'; - const ENDS_WITH = 'ENDS WITH'; - const CONTAINS = 'CONTAINS'; - const DOES_NOT_CONTAIN = 'DOES NOT CONTAIN'; - const AT_LEAST_COMPLETE = 'AT LEAST COMPLETE'; - const AT_LEAST_INCOMPLETE = 'AT LEAST INCOMPLETE'; - const ALL_COMPLETE = 'ALL COMPLETE'; - const ALL_INCOMPLETE = 'ALL INCOMPLETE'; + public const EQUAL = '='; + public const NOT_EQUAL = '!='; + public const GREATER_THAN = '>'; + public const GREATER_THAN_OR_EQUAL = '>='; + public const LOWER_THAN = '<'; + public const LOWER_THAN_OR_EQUAL = '<='; + public const IN = 'IN'; + public const NOT_IN = 'NOT IN'; + public const IN_OR_UNCLASSIFIED = 'IN OR UNCLASSIFIED'; + public const IN_CHILDREN = 'IN CHILDREN'; + public const NOT_IN_CHILDREN = 'NOT IN CHILDREN'; + public const UNCLASSIFIED = 'UNCLASSIFIED'; + public const GREATER_THAN_ON_ALL_LOCALES = 'GREATER THAN ON ALL LOCALES'; + public const GREATER_OR_EQUALS_THAN_ON_ALL_LOCALES = 'GREATER OR EQUALS THAN ON ALL LOCALES'; + public const LOWER_THAN_ON_ALL_LOCALES = 'LOWER THAN ON ALL LOCALES'; + public const LOWER_OR_EQUALS_THAN_ON_ALL_LOCALES = 'LOWER OR EQUALS THAN ON ALL LOCALES'; + public const IS_EMPTY = 'EMPTY'; + public const NOT_EMPTY = 'NOT EMPTY'; + public const BETWEEN = 'BETWEEN'; + public const NOT_BETWEEN = 'NOT BETWEEN'; + public const SINCE_LAST_N_DAYS = 'SINCE LAST N DAYS'; + public const STARTS_WITH = 'STARTS WITH'; + public const ENDS_WITH = 'ENDS WITH'; + public const CONTAINS = 'CONTAINS'; + public const DOES_NOT_CONTAIN = 'DOES NOT CONTAIN'; + public const AT_LEAST_COMPLETE = 'AT LEAST COMPLETE'; + public const AT_LEAST_INCOMPLETE = 'AT LEAST INCOMPLETE'; + public const ALL_COMPLETE = 'ALL COMPLETE'; + public const ALL_INCOMPLETE = 'ALL INCOMPLETE'; } diff --git a/src/Stream/UpsertResourceListResponseFactory.php b/src/Stream/UpsertResourceListResponseFactory.php index f2e82592..61777220 100644 --- a/src/Stream/UpsertResourceListResponseFactory.php +++ b/src/Stream/UpsertResourceListResponseFactory.php @@ -13,7 +13,7 @@ */ class UpsertResourceListResponseFactory { - public function create(StreamInterface $bodyStream): UpsertResourceListResponse + public function create(StreamInterface $bodyStream): UpsertResourceListResponse { return new UpsertResourceListResponse($bodyStream, new LineStreamReader()); } From 29e1e0ec9209031b3f95b29dd1f004728c28d46a Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Fri, 4 Nov 2022 17:20:03 +0100 Subject: [PATCH 4/8] chore(API-1925): Add ecs and new rules --- .php_cs.php | 13 ------------ Makefile | 4 ++-- composer.json | 3 ++- composer.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- ecs.php | 29 ++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 17 deletions(-) delete mode 100644 .php_cs.php create mode 100644 ecs.php diff --git a/.php_cs.php b/.php_cs.php deleted file mode 100644 index e6a6be84..00000000 --- a/.php_cs.php +++ /dev/null @@ -1,13 +0,0 @@ -setRules(array( - '@PSR12' => true, - 'linebreak_after_opening_tag' => true, - 'ordered_imports' => true, - )) - ->setFinder( - PhpCsFixer\Finder::create() - ->name('*.php') - ->in(__DIR__ . '/src') - ); diff --git a/Makefile b/Makefile index 9962f786..8bc9d960 100644 --- a/Makefile +++ b/Makefile @@ -37,11 +37,11 @@ cs: ## Run code style check @echo "------------------" @echo "- PHP code style -" @echo "------------------" - $(DOCKER_RUN) bin/php-cs-fixer fix --diff --dry-run --config=.php_cs.php -vvv + $(DOCKER_RUN) bin/ecs .PHONY: fix-cs fix-cs: ## Fix PHP code style - $(DOCKER_RUN) bin/php-cs-fixer fix --config=.php_cs.php + $(DOCKER_RUN) bin/ecs --fix .PHONY: rector rector: ## Run rector diff --git a/composer.json b/composer.json index 7ee50a20..166c2d30 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "donatj/mock-webserver": "^2.0", "http-interop/http-factory-guzzle": "^1.0", "php-http/guzzle6-adapter": "^2.0", - "rector/rector": "^0.14.6" + "rector/rector": "^0.14.6", + "symplify/easy-coding-standard": "^11.1" }, "config": { "bin-dir": "bin", diff --git a/composer.lock b/composer.lock index 6ccc861b..b9c2f2b2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0d6b733646d3909893d6a3b95dda42d7", + "content-hash": "e4a23e97ad1a5ad8af7dcc2efd774ff0", "packages": [ { "name": "guzzlehttp/psr7", @@ -5180,6 +5180,61 @@ ], "time": "2022-08-02T15:47:23+00:00" }, + { + "name": "symplify/easy-coding-standard", + "version": "11.1.16", + "source": { + "type": "git", + "url": "https://github.com/symplify/easy-coding-standard.git", + "reference": "32ebd57f0f47713540df8ea39134adaa9d912fae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/32ebd57f0f47713540df8ea39134adaa9d912fae", + "reference": "32ebd57f0f47713540df8ea39134adaa9d912fae", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "conflict": { + "friendsofphp/php-cs-fixer": "<3.0", + "squizlabs/php_codesniffer": "<3.6" + }, + "bin": [ + "bin/ecs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.3-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Prefixed scoped version of ECS package", + "support": { + "source": "https://github.com/symplify/easy-coding-standard/tree/11.1.16" + }, + "funding": [ + { + "url": "https://www.paypal.me/rectorphp", + "type": "custom" + }, + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2022-10-27T10:48:13+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/ecs.php b/ecs.php new file mode 100644 index 00000000..4d7bfc8b --- /dev/null +++ b/ecs.php @@ -0,0 +1,29 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + __DIR__ . '/spec' + ]); + + $ecsConfig->sets([SetList::PSR_12]); + + $ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [ + 'syntax' => 'short', + ]); + + $ecsConfig->ruleWithConfiguration(LineLengthFixer::class, [ + LineLengthFixer::LINE_LENGTH => 140, + LineLengthFixer::INLINE_SHORT_LINES => false, + LineLengthFixer::BREAK_LONG_LINES => true, + ]); + + $ecsConfig->rule(StandaloneLinePromotedPropertyFixer::class); +}; From 140fb81c2fdd48cd31af0ea40b2065711c1bb67c Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Mon, 7 Nov 2022 11:05:18 +0100 Subject: [PATCH 5/8] refact(API-1925): Remove deprecated phpunit annotations --- .../GetAssetFamilyAttributeIntegration.php | 9 +++++---- .../GetAssetFamilyAttributeOptionIntegration.php | 9 +++++---- tests/Api/AssetFamily/GetAssetFamilyIntegration.php | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php b/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php index d3146902..e286b4de 100644 --- a/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php +++ b/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php @@ -5,6 +5,7 @@ namespace Akeneo\Pim\ApiClient\tests\Api\AssetAttribute; use Akeneo\Pim\ApiClient\Api\AssetManager\AssetAttributeApi; +use Akeneo\Pim\ApiClient\Exception\NotFoundHttpException; use Akeneo\Pim\ApiClient\tests\Api\ApiTestCase; use donatj\MockWebServer\RequestInfo; use donatj\MockWebServer\Response; @@ -29,10 +30,6 @@ public function test_get_asset_family_attribute() Assert::assertEquals($familyAttribute, json_decode($this->getPackshotPreviewAttribute(), true)); } - /** - * @expectedException \Akeneo\Pim\ApiClient\Exception\NotFoundHttpException - * @expectedExceptionMessage Resource `foo` does not exist. - */ public function test_get_unknown_asset_family_attribute() { $this->server->setResponseOfPath( @@ -43,6 +40,10 @@ public function test_get_unknown_asset_family_attribute() ); $api = $this->createClientByPassword()->getAssetAttributeApi(); + + $this->expectException(NotFoundHttpException::class); + $this->expectExceptionMessage('Resource `foo` does not exist.'); + $api->get('packshot', 'foo'); } diff --git a/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php b/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php index eb161d6e..54bc64db 100644 --- a/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php +++ b/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php @@ -5,6 +5,7 @@ namespace Akeneo\Pim\ApiClient\tests\Api\AssetAttributeOption; use Akeneo\Pim\ApiClient\Api\AssetManager\AssetAttributeOptionApi; +use Akeneo\Pim\ApiClient\Exception\NotFoundHttpException; use Akeneo\Pim\ApiClient\tests\Api\ApiTestCase; use donatj\MockWebServer\RequestInfo; use donatj\MockWebServer\Response; @@ -29,10 +30,6 @@ public function test_get_asset_family_attribute_option() Assert::assertEquals($familyAttributeOption, json_decode($this->getPackshotAttributeOption(), true)); } - /** - * @expectedException \Akeneo\Pim\ApiClient\Exception\NotFoundHttpException - * @expectedExceptionMessage Resource `XLS` does not exist. - */ public function test_get_unknown_asset_family_attribute_option() { $this->server->setResponseOfPath( @@ -43,6 +40,10 @@ public function test_get_unknown_asset_family_attribute_option() ); $api = $this->createClientByPassword()->getAssetAttributeOptionApi(); + + $this->expectException(NotFoundHttpException::class); + $this->expectExceptionMessage('Resource `XLS` does not exist.'); + $api->get('packshot', 'wearing_model_size', 'XLS'); } diff --git a/tests/Api/AssetFamily/GetAssetFamilyIntegration.php b/tests/Api/AssetFamily/GetAssetFamilyIntegration.php index 841339da..eb4ed095 100644 --- a/tests/Api/AssetFamily/GetAssetFamilyIntegration.php +++ b/tests/Api/AssetFamily/GetAssetFamilyIntegration.php @@ -5,6 +5,7 @@ namespace Akeneo\Pim\ApiClient\tests\Api\AssetFamily; use Akeneo\Pim\ApiClient\Api\AssetManager\AssetFamilyApi; +use Akeneo\Pim\ApiClient\Exception\NotFoundHttpException; use Akeneo\Pim\ApiClient\tests\Api\ApiTestCase; use donatj\MockWebServer\RequestInfo; use donatj\MockWebServer\Response; @@ -29,10 +30,6 @@ public function test_get_asset_family() Assert::assertEquals($product, json_decode($this->getPackshot(), true)); } - /** - * @expectedException \Akeneo\Pim\ApiClient\Exception\NotFoundHttpException - * @expectedExceptionMessage Asset family "foo" does not exist. - */ public function test_get_unknown_asset_family() { $this->server->setResponseOfPath( @@ -43,6 +40,10 @@ public function test_get_unknown_asset_family() ); $api = $this->createClientByPassword()->getAssetFamilyApi(); + + $this->expectException(NotFoundHttpException::class); + $this->expectExceptionMessage('Asset family "foo" does not exist.'); + $api->get('foo'); } From f2f89f8bf40330c81575d21ffabf48ce02908725 Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Mon, 7 Nov 2022 11:18:23 +0100 Subject: [PATCH 6/8] refact(API-1925): Run rector --- spec/Routing/UriGeneratorSpec.php | 2 +- spec/Security/AuthenticationSpec.php | 7 +- src/AkeneoPimClient.php | 120 +----------------- src/AkeneoPimClientBuilder.php | 26 +--- src/Api/AppCatalog/AppCatalogApi.php | 14 +- src/Api/AppCatalog/AppCatalogProductApi.php | 14 +- src/Api/AssetApi.php | 19 +-- src/Api/AssetCategoryApi.php | 19 +-- src/Api/AssetManager/AssetApi.php | 19 +-- src/Api/AssetManager/AssetAttributeApi.php | 6 +- .../AssetManager/AssetAttributeOptionApi.php | 6 +- src/Api/AssetManager/AssetFamilyApi.php | 19 +-- src/Api/AssetManager/AssetMediaFileApi.php | 14 +- src/Api/AssetReferenceFileApi.php | 14 +- src/Api/AssetTagApi.php | 19 +-- src/Api/AssetVariationFileApi.php | 15 +-- src/Api/AssociationTypeApi.php | 24 +--- src/Api/AttributeApi.php | 24 +--- src/Api/AttributeGroupApi.php | 24 +--- src/Api/AttributeOptionApi.php | 24 +--- src/Api/AuthenticationApi.php | 18 +-- src/Api/CategoryApi.php | 24 +--- src/Api/ChannelApi.php | 24 +--- src/Api/CurrencyApi.php | 24 +--- src/Api/FamilyApi.php | 24 +--- src/Api/FamilyVariantApi.php | 24 +--- src/Api/LocaleApi.php | 24 +--- src/Api/MeasureFamilyApi.php | 24 +--- src/Api/MeasurementFamilyApi.php | 9 +- .../UpsertableResourceListInterface.php | 2 +- src/Api/ProductApi.php | 24 +--- src/Api/ProductDraftApi.php | 19 +-- src/Api/ProductDraftUuidApi.php | 14 +- src/Api/ProductMediaFileApi.php | 32 +---- src/Api/ProductModelApi.php | 24 +--- src/Api/ProductModelDraftApi.php | 19 +-- src/Api/ProductUuidApi.php | 14 +- src/Api/PublishedProductApi.php | 19 +-- src/Api/ReferenceEntityApi.php | 19 +-- src/Api/ReferenceEntityAttributeApi.php | 6 +- src/Api/ReferenceEntityAttributeOptionApi.php | 6 +- src/Api/ReferenceEntityMediaFileApi.php | 14 +- src/Api/ReferenceEntityRecordApi.php | 19 +-- src/Cache/CacheInterface.php | 4 +- src/Cache/LRUCache.php | 8 +- src/Client/AuthenticatedHttpClient.php | 21 +-- src/Client/CachedResourceClient.php | 11 +- src/Client/HttpClient.php | 20 +-- src/Client/HttpExceptionHandler.php | 4 - src/Client/Options.php | 5 +- src/Client/ResourceClient.php | 17 +-- src/Exception/HttpException.php | 7 +- ...UploadAssetReferenceFileErrorException.php | 8 +- .../MultipartStreamBuilder.php | 31 ++--- src/Pagination/Page.php | 39 +----- src/Pagination/PageFactory.php | 6 +- src/Pagination/ResourceCursor.php | 7 +- src/Routing/UriGenerator.php | 2 - src/Search/SearchBuilder.php | 2 - src/Stream/LineStreamReader.php | 2 - src/Stream/MultipartStreamBuilderFactory.php | 6 +- src/Stream/UpsertResourceListResponse.php | 10 +- .../ListAllAssetFamiliesIntegration.php | 2 +- 63 files changed, 110 insertions(+), 957 deletions(-) diff --git a/spec/Routing/UriGeneratorSpec.php b/spec/Routing/UriGeneratorSpec.php index b92f589a..ac012430 100644 --- a/spec/Routing/UriGeneratorSpec.php +++ b/spec/Routing/UriGeneratorSpec.php @@ -6,7 +6,7 @@ class UriGeneratorSpec extends ObjectBehavior { - const BASE_URI = 'http://akeneo-pim.local/'; + public const BASE_URI = 'http://akeneo-pim.local/'; function let() { diff --git a/spec/Security/AuthenticationSpec.php b/spec/Security/AuthenticationSpec.php index 9ece8248..830d8b15 100644 --- a/spec/Security/AuthenticationSpec.php +++ b/spec/Security/AuthenticationSpec.php @@ -2,6 +2,7 @@ namespace spec\Akeneo\Pim\ApiClient\Security; +use Akeneo\Pim\ApiClient\Security\Authentication; use PhpSpec\ObjectBehavior; class AuthenticationSpec extends ObjectBehavior @@ -9,7 +10,7 @@ class AuthenticationSpec extends ObjectBehavior function it_is_initializable_from_a_password() { $this->beConstructedThrough('fromPassword', ['client_id', 'secret', 'Julia', 'Julia_pwd']); - $this->shouldHaveType('Akeneo\Pim\ApiClient\Security\Authentication'); + $this->shouldHaveType(Authentication::class); $this->getClientId()->shouldReturn('client_id'); $this->getSecret()->shouldReturn('secret'); @@ -22,7 +23,7 @@ function it_is_initializable_from_a_password() function it_is_initializable_from_a_token() { $this->beConstructedThrough('fromToken', ['client_id', 'secret', 'token', 'refresh_token']); - $this->shouldHaveType('Akeneo\Pim\ApiClient\Security\Authentication'); + $this->shouldHaveType(Authentication::class); $this->getClientId()->shouldReturn('client_id'); $this->getSecret()->shouldReturn('secret'); @@ -35,7 +36,7 @@ function it_is_initializable_from_a_token() function it_is_initializable_from_an_app_token() { $this->beConstructedThrough('fromAppToken', ['a_token']); - $this->shouldHaveType('Akeneo\Pim\ApiClient\Security\Authentication'); + $this->shouldHaveType(Authentication::class); $this->getClientId()->shouldReturn(null); $this->getSecret()->shouldReturn(null); diff --git a/src/AkeneoPimClient.php b/src/AkeneoPimClient.php index c06b0a00..2ccbd331 100644 --- a/src/AkeneoPimClient.php +++ b/src/AkeneoPimClient.php @@ -50,124 +50,8 @@ */ class AkeneoPimClient implements AkeneoPimClientInterface { - protected Authentication $authentication; - protected ProductApiInterface $productApi; - protected CategoryApiInterface $categoryApi; - protected AttributeApiInterface $attributeApi; - protected AttributeOptionApiInterface $attributeOptionApi; - protected AttributeGroupApiInterface $attributeGroupApi; - protected FamilyApiInterface $familyApi; - protected MediaFileApiInterface $productMediaFileApi; - protected LocaleApiInterface $localeApi; - protected ChannelApiInterface $channelApi; - protected CurrencyApiInterface $currencyApi; - protected MeasureFamilyApiInterface $measureFamilyApi; - protected AssociationTypeApiInterface $associationTypeApi; - protected FamilyVariantApiInterface $familyVariantApi; - protected ProductModelApiInterface $productModelApi; - private MeasurementFamilyApiInterface $measurementFamilyApi; - private PublishedProductApiInterface $publishedProductApi; - private ProductModelDraftApiInterface $productModelDraftApi; - private ProductDraftApiInterface $productDraftApi; - private AssetApiInterface $assetApi; - private AssetCategoryApiInterface $assetCategoryApi; - private AssetTagApiInterface $assetTagApi; - private AssetReferenceFileApiInterface $assetReferenceFileApi; - private AssetVariationFileApiInterface $assetVariationFileApi; - private ReferenceEntityRecordApiInterface $referenceEntityRecordApi; - private ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi; - private ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi; - private ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi; - private ReferenceEntityApiInterface $referenceEntityApi; - private AssetManagerApiInterface $assetManagerApi; - private AssetFamilyApiInterface $assetFamilyApi; - private AssetAttributeApiInterface $assetAttributeApi; - private AssetAttributeOptionApiInterface $assetAttributeOptionApi; - private AssetMediaFileApiInterface $assetMediaFileApi; - private AppCatalogApiInterface $appCatalogApi; - private AppCatalogProductApiInterface $appCatalogProductApi; - - private ProductUuidApiInterface $productUuidApi; - private ProductDraftUuidApiInterface $productDraftUuidApi; - - public function __construct( - Authentication $authentication, - ProductApiInterface $productApi, - CategoryApiInterface $categoryApi, - AttributeApiInterface $attributeApi, - AttributeOptionApiInterface $attributeOptionApi, - AttributeGroupApiInterface $attributeGroupApi, - FamilyApiInterface $familyApi, - MediaFileApiInterface $productMediaFileApi, - LocaleApiInterface $localeApi, - ChannelApiInterface $channelApi, - CurrencyApiInterface $currencyApi, - MeasureFamilyApiInterface $measureFamilyApi, - MeasurementFamilyApiInterface $measurementFamilyApi, - AssociationTypeApiInterface $associationTypeApi, - FamilyVariantApiInterface $familyVariantApi, - ProductModelApiInterface $productModelApi, - ProductModelDraftApiInterface $productModelDraftApi, - PublishedProductApiInterface $publishedProductApi, - ProductDraftApiInterface $productDraftApi, - AssetApiInterface $assetApi, - AssetCategoryApiInterface $assetCategoryApi, - AssetTagApiInterface $assetTagApi, - AssetReferenceFileApiInterface $assetReferenceFileApi, - AssetVariationFileApiInterface $assetVariationFileApi, - ReferenceEntityRecordApiInterface $referenceEntityRecordApi, - ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi, - ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi, - ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi, - ReferenceEntityApiInterface $referenceEntityApi, - AssetManagerApiInterface $assetManagerApi, - AssetFamilyApiInterface $assetFamilyApi, - AssetAttributeApiInterface $assetAttributeApi, - AssetAttributeOptionApiInterface $assetAttributeOptionApi, - AssetMediaFileApiInterface $assetMediaFileApi, - ProductUuidApiInterface $productUuidApi, - ProductDraftUuidApiInterface $productDraftUuidApi, - AppCatalogApiInterface $appCatalogApi, - AppCatalogProductApiInterface $appCatalogProductApi - ) { - $this->authentication = $authentication; - $this->productApi = $productApi; - $this->categoryApi = $categoryApi; - $this->attributeApi = $attributeApi; - $this->attributeOptionApi = $attributeOptionApi; - $this->attributeGroupApi = $attributeGroupApi; - $this->familyApi = $familyApi; - $this->productMediaFileApi = $productMediaFileApi; - $this->localeApi = $localeApi; - $this->channelApi = $channelApi; - $this->currencyApi = $currencyApi; - $this->measureFamilyApi = $measureFamilyApi; - $this->measurementFamilyApi = $measurementFamilyApi; - $this->associationTypeApi = $associationTypeApi; - $this->familyVariantApi = $familyVariantApi; - $this->productModelApi = $productModelApi; - $this->publishedProductApi = $publishedProductApi; - $this->productDraftApi = $productDraftApi; - $this->productModelDraftApi = $productModelDraftApi; - $this->assetApi = $assetApi; - $this->assetCategoryApi = $assetCategoryApi; - $this->assetTagApi = $assetTagApi; - $this->assetReferenceFileApi = $assetReferenceFileApi; - $this->assetVariationFileApi = $assetVariationFileApi; - $this->referenceEntityRecordApi = $referenceEntityRecordApi; - $this->referenceEntityMediaFileApi = $referenceEntityMediaFileApi; - $this->referenceEntityAttributeApi = $referenceEntityAttributeApi; - $this->referenceEntityAttributeOptionApi = $referenceEntityAttributeOptionApi; - $this->referenceEntityApi = $referenceEntityApi; - $this->assetManagerApi = $assetManagerApi; - $this->assetFamilyApi = $assetFamilyApi; - $this->assetAttributeApi = $assetAttributeApi; - $this->assetAttributeOptionApi = $assetAttributeOptionApi; - $this->assetMediaFileApi = $assetMediaFileApi; - $this->productUuidApi = $productUuidApi; - $this->productDraftUuidApi = $productDraftUuidApi; - $this->appCatalogApi = $appCatalogApi; - $this->appCatalogProductApi = $appCatalogProductApi; + public function __construct(protected Authentication $authentication, protected ProductApiInterface $productApi, protected CategoryApiInterface $categoryApi, protected AttributeApiInterface $attributeApi, protected AttributeOptionApiInterface $attributeOptionApi, protected AttributeGroupApiInterface $attributeGroupApi, protected FamilyApiInterface $familyApi, protected MediaFileApiInterface $productMediaFileApi, protected LocaleApiInterface $localeApi, protected ChannelApiInterface $channelApi, protected CurrencyApiInterface $currencyApi, protected MeasureFamilyApiInterface $measureFamilyApi, private MeasurementFamilyApiInterface $measurementFamilyApi, protected AssociationTypeApiInterface $associationTypeApi, protected FamilyVariantApiInterface $familyVariantApi, protected ProductModelApiInterface $productModelApi, private ProductModelDraftApiInterface $productModelDraftApi, private PublishedProductApiInterface $publishedProductApi, private ProductDraftApiInterface $productDraftApi, private AssetApiInterface $assetApi, private AssetCategoryApiInterface $assetCategoryApi, private AssetTagApiInterface $assetTagApi, private AssetReferenceFileApiInterface $assetReferenceFileApi, private AssetVariationFileApiInterface $assetVariationFileApi, private ReferenceEntityRecordApiInterface $referenceEntityRecordApi, private ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi, private ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi, private ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi, private ReferenceEntityApiInterface $referenceEntityApi, private AssetManagerApiInterface $assetManagerApi, private AssetFamilyApiInterface $assetFamilyApi, private AssetAttributeApiInterface $assetAttributeApi, private AssetAttributeOptionApiInterface $assetAttributeOptionApi, private AssetMediaFileApiInterface $assetMediaFileApi, private ProductUuidApiInterface $productUuidApi, private ProductDraftUuidApiInterface $productDraftUuidApi, private AppCatalogApiInterface $appCatalogApi, private AppCatalogProductApiInterface $appCatalogProductApi) + { } /** diff --git a/src/AkeneoPimClientBuilder.php b/src/AkeneoPimClientBuilder.php index be777a0f..b6081000 100644 --- a/src/AkeneoPimClientBuilder.php +++ b/src/AkeneoPimClientBuilder.php @@ -70,9 +70,6 @@ */ class AkeneoPimClientBuilder { - /** @var string */ - protected $baseUri; - /** @var ClientInterface */ protected $httpClient; @@ -92,9 +89,8 @@ class AkeneoPimClientBuilder /** * @param string $baseUri Base uri to request the API */ - public function __construct(string $baseUri, array $options = []) + public function __construct(protected string $baseUri, array $options = []) { - $this->baseUri = $baseUri; $this->options = Options::fromArray($options); } @@ -130,10 +126,6 @@ public function setStreamFactory(StreamFactoryInterface $streamFactory): self /** * Allows to define another implementation than LocalFileSystem - * - * @param FileSystemInterface $fileSystem - * - * @return AkeneoPimClientBuilder */ public function setFileSystem(FileSystemInterface $fileSystem): self { @@ -149,8 +141,6 @@ public function setFileSystem(FileSystemInterface $fileSystem): self * @param string $secret Secret associated to the client * @param string $username Username to use for the authentication * @param string $password Password associated to the username - * - * @return AkeneoPimClientInterface */ public function buildAuthenticatedByPassword(string $clientId, string $secret, string $username, string $password): AkeneoPimClientInterface { @@ -173,8 +163,6 @@ public function buildAuthenticatedByAppToken(string $token): AkeneoPimClientInte * @param string $secret Secret associated to the client * @param string $token Token to use for the authentication * @param string $refreshToken Token to use to refresh the access token - * - * @return AkeneoPimClientInterface */ public function buildAuthenticatedByToken(string $clientId, string $secret, string $token, string $refreshToken): AkeneoPimClientInterface { @@ -205,16 +193,11 @@ public function disableCache(): self return $this; } - /** - * @param Authentication $authentication - * - * @return AkeneoPimClientInterface - */ protected function buildAuthenticatedClient(Authentication $authentication): AkeneoPimClientInterface { [$resourceClient, $pageFactory, $cursorFactory, $fileSystem] = $this->setUp($authentication); - $resourceClientWithCache = !$this->cacheEnabled ? $resourceClient : new CachedResourceClient($resourceClient, new LRUCache()); + $resourceClientWithCache = $this->cacheEnabled ? new CachedResourceClient($resourceClient, new LRUCache()) : $resourceClient; return new AkeneoPimClient( $authentication, @@ -258,11 +241,6 @@ protected function buildAuthenticatedClient(Authentication $authentication): Ake ); } - /** - * @param Authentication $authentication - * - * @return array - */ protected function setUp(Authentication $authentication): array { $uriGenerator = new UriGenerator($this->baseUri); diff --git a/src/Api/AppCatalog/AppCatalogApi.php b/src/Api/AppCatalog/AppCatalogApi.php index 93da7076..2fee8662 100644 --- a/src/Api/AppCatalog/AppCatalogApi.php +++ b/src/Api/AppCatalog/AppCatalogApi.php @@ -20,18 +20,8 @@ class AppCatalogApi implements AppCatalogApiInterface public const APP_CATALOGS_URI = 'api/rest/v1/catalogs'; public const APP_CATALOG_URI = 'api/rest/v1/catalogs/%s'; - protected ResourceClientInterface $resourceClient; - protected PageFactoryInterface $pageFactory; - protected ResourceCursorFactoryInterface $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } public function listPerPage(int $limit = 100, bool $withCount = false, array $queryParameters = []): PageInterface diff --git a/src/Api/AppCatalog/AppCatalogProductApi.php b/src/Api/AppCatalog/AppCatalogProductApi.php index 3ff26409..ef09ec67 100644 --- a/src/Api/AppCatalog/AppCatalogProductApi.php +++ b/src/Api/AppCatalog/AppCatalogProductApi.php @@ -17,18 +17,8 @@ class AppCatalogProductApi implements AppCatalogProductApiInterface { public const APP_CATALOG_PRODUCT_URI = '/api/rest/v1/catalogs/%s/product-uuids'; - protected ResourceClientInterface $resourceClient; - protected PageFactoryInterface $pageFactory; - protected ResourceCursorFactoryInterface $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AssetApi.php b/src/Api/AssetApi.php index 338b4d2c..8fabde31 100644 --- a/src/Api/AssetApi.php +++ b/src/Api/AssetApi.php @@ -25,23 +25,8 @@ class AssetApi implements AssetApiInterface public const ASSETS_URI = '/api/rest/v1/assets'; public const ASSET_URI = '/api/rest/v1/assets/%s'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AssetCategoryApi.php b/src/Api/AssetCategoryApi.php index 262fc780..4180bce5 100644 --- a/src/Api/AssetCategoryApi.php +++ b/src/Api/AssetCategoryApi.php @@ -25,23 +25,8 @@ class AssetCategoryApi implements AssetCategoryApiInterface public const ASSET_CATEGORIES_URI = '/api/rest/v1/asset-categories'; public const ASSET_CATEGORY_URI = '/api/rest/v1/asset-categories/%s'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AssetManager/AssetApi.php b/src/Api/AssetManager/AssetApi.php index 7d333731..96b3047f 100644 --- a/src/Api/AssetManager/AssetApi.php +++ b/src/Api/AssetManager/AssetApi.php @@ -14,23 +14,8 @@ class AssetApi implements AssetApiInterface public const ASSET_URI= 'api/rest/v1/asset-families/%s/assets/%s'; public const ASSETS_URI = 'api/rest/v1/asset-families/%s/assets'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AssetManager/AssetAttributeApi.php b/src/Api/AssetManager/AssetAttributeApi.php index c1ded5fc..9a803612 100644 --- a/src/Api/AssetManager/AssetAttributeApi.php +++ b/src/Api/AssetManager/AssetAttributeApi.php @@ -11,12 +11,8 @@ class AssetAttributeApi implements AssetAttributeApiInterface public const ASSET_ATTRIBUTE_URI = 'api/rest/v1/asset-families/%s/attributes/%s'; public const ASSET_ATTRIBUTES_URI = 'api/rest/v1/asset-families/%s/attributes'; - /** @var ResourceClientInterface */ - private $resourceClient; - - public function __construct(ResourceClientInterface $resourceClient) + public function __construct(private ResourceClientInterface $resourceClient) { - $this->resourceClient = $resourceClient; } /** diff --git a/src/Api/AssetManager/AssetAttributeOptionApi.php b/src/Api/AssetManager/AssetAttributeOptionApi.php index a227b540..5a17b9e3 100644 --- a/src/Api/AssetManager/AssetAttributeOptionApi.php +++ b/src/Api/AssetManager/AssetAttributeOptionApi.php @@ -11,12 +11,8 @@ class AssetAttributeOptionApi implements AssetAttributeOptionApiInterface public const ASSET_ATTRIBUTE_OPTION_URI = 'api/rest/v1/asset-families/%s/attributes/%s/options/%s'; public const ASSET_ATTRIBUTE_OPTIONS_URI = 'api/rest/v1/asset-families/%s/attributes/%s/options'; - /** @var ResourceClientInterface */ - private $resourceClient; - - public function __construct(ResourceClientInterface $resourceClient) + public function __construct(private ResourceClientInterface $resourceClient) { - $this->resourceClient = $resourceClient; } /** diff --git a/src/Api/AssetManager/AssetFamilyApi.php b/src/Api/AssetManager/AssetFamilyApi.php index 52a38a3e..a294f3dd 100644 --- a/src/Api/AssetManager/AssetFamilyApi.php +++ b/src/Api/AssetManager/AssetFamilyApi.php @@ -14,23 +14,8 @@ class AssetFamilyApi implements AssetFamilyApiInterface public const ASSET_FAMILY_URI = 'api/rest/v1/asset-families/%s'; public const ASSET_FAMILIES_URI= 'api/rest/v1/asset-families'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AssetManager/AssetMediaFileApi.php b/src/Api/AssetManager/AssetMediaFileApi.php index 8d3db5a9..d5e61807 100644 --- a/src/Api/AssetManager/AssetMediaFileApi.php +++ b/src/Api/AssetManager/AssetMediaFileApi.php @@ -14,16 +14,8 @@ class AssetMediaFileApi implements AssetMediaFileApiInterface public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/asset-media-files/%s'; public const MEDIA_FILE_CREATE_URI = 'api/rest/v1/asset-media-files'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var FileSystemInterface */ - private $fileSystem; - - public function __construct(ResourceClientInterface $resourceClient, FileSystemInterface $fileSystem) + public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) { - $this->resourceClient = $resourceClient; - $this->fileSystem = $fileSystem; } /** @@ -58,11 +50,7 @@ public function create($mediaFile): string /** * Extracts the code of a media-file from a creation response. * - * @param ResponseInterface $response - * * @throws RuntimeException if unable to extract the code - * - * @return string */ private function extractCodeFromCreationResponse(ResponseInterface $response): string { diff --git a/src/Api/AssetReferenceFileApi.php b/src/Api/AssetReferenceFileApi.php index 129b80a7..1eb52ebc 100644 --- a/src/Api/AssetReferenceFileApi.php +++ b/src/Api/AssetReferenceFileApi.php @@ -24,16 +24,8 @@ class AssetReferenceFileApi implements AssetReferenceFileApiInterface public const ASSET_REFERENCE_FILE_DOWNLOAD_URI = '/api/rest/v1/assets/%s/reference-files/%s/download'; public const NOT_LOCALIZABLE_ASSET_LOCALE_CODE = 'no-locale'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var FileSystemInterface */ - private $fileSystem; - - public function __construct(ResourceClientInterface $resourceClient, FileSystemInterface $fileSystem) + public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) { - $this->resourceClient = $resourceClient; - $this->fileSystem = $fileSystem; } /** @@ -88,10 +80,6 @@ public function downloadFromNotLocalizableAsset(string $assetCode): ResponseInte /** * @param string|resource $referenceFile - * @param string $assetCode - * @param string $localeCode - * - * @return int */ private function upload($referenceFile, string $assetCode, string $localeCode): int { diff --git a/src/Api/AssetTagApi.php b/src/Api/AssetTagApi.php index cc52bdbe..672b4fbc 100644 --- a/src/Api/AssetTagApi.php +++ b/src/Api/AssetTagApi.php @@ -23,23 +23,8 @@ class AssetTagApi implements AssetTagApiInterface public const ASSET_TAGS_URI = '/api/rest/v1/asset-tags'; public const ASSET_TAG_URI = '/api/rest/v1/asset-tags/%s'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AssetVariationFileApi.php b/src/Api/AssetVariationFileApi.php index 53b42626..abfbd8a4 100644 --- a/src/Api/AssetVariationFileApi.php +++ b/src/Api/AssetVariationFileApi.php @@ -22,16 +22,8 @@ class AssetVariationFileApi implements AssetVariationFileApiInterface public const ASSET_VARIATION_FILE_DOWNLOAD_URI = '/api/rest/v1/assets/%s/variation-files/%s/%s/download'; public const NOT_LOCALIZABLE_ASSET_LOCALE_CODE = 'no-locale'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var FileSystemInterface */ - private $fileSystem; - - public function __construct(ResourceClientInterface $resourceClient, FileSystemInterface $fileSystem) + public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) { - $this->resourceClient = $resourceClient; - $this->fileSystem = $fileSystem; } /** @@ -95,11 +87,6 @@ private function get(string $assetCode, string $channelCode, string $localeCode) /** * @param string|resource $variationFile - * @param string $assetCode - * @param string $channelCode - * @param string $localeCode - * - * @return int */ private function upload($variationFile, string $assetCode, string $channelCode, string $localeCode): int { diff --git a/src/Api/AssociationTypeApi.php b/src/Api/AssociationTypeApi.php index 334129ab..5dfe2541 100644 --- a/src/Api/AssociationTypeApi.php +++ b/src/Api/AssociationTypeApi.php @@ -19,28 +19,8 @@ class AssociationTypeApi implements AssociationTypeApiInterface public const ASSOCIATION_TYPES_URI = 'api/rest/v1/association-types'; public const ASSOCIATION_TYPE_URI = 'api/rest/v1/association-types/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** * {@inheritdoc} diff --git a/src/Api/AttributeApi.php b/src/Api/AttributeApi.php index 37b137a4..9258fbe9 100644 --- a/src/Api/AttributeApi.php +++ b/src/Api/AttributeApi.php @@ -21,28 +21,8 @@ class AttributeApi implements AttributeApiInterface public const ATTRIBUTES_URI = 'api/rest/v1/attributes'; public const ATTRIBUTE_URI = 'api/rest/v1/attributes/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AttributeGroupApi.php b/src/Api/AttributeGroupApi.php index fb74831a..5f8b4585 100644 --- a/src/Api/AttributeGroupApi.php +++ b/src/Api/AttributeGroupApi.php @@ -21,28 +21,8 @@ class AttributeGroupApi implements AttributeGroupApiInterface public const ATTRIBUTE_GROUP_URI = 'api/rest/v1/attribute-groups/%s'; public const ATTRIBUTE_GROUPS_URI = 'api/rest/v1/attribute-groups'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AttributeOptionApi.php b/src/Api/AttributeOptionApi.php index 3e169d80..cb3305a6 100644 --- a/src/Api/AttributeOptionApi.php +++ b/src/Api/AttributeOptionApi.php @@ -21,28 +21,8 @@ class AttributeOptionApi implements AttributeOptionApiInterface public const ATTRIBUTE_OPTIONS_URI = 'api/rest/v1/attributes/%s/options'; public const ATTRIBUTE_OPTION_URI = 'api/rest/v1/attributes/%s/options/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/AuthenticationApi.php b/src/Api/AuthenticationApi.php index 8506bd5a..eb9fa47e 100644 --- a/src/Api/AuthenticationApi.php +++ b/src/Api/AuthenticationApi.php @@ -16,20 +16,8 @@ class AuthenticationApi implements AuthenticationApiInterface { public const TOKEN_URI = 'api/oauth/v1/token'; - /** @var HttpClient */ - protected $httpClient; - - /** @var UriGeneratorInterface */ - protected $uriGenerator; - - /** - * @param HttpClient $httpClient - * @param UriGeneratorInterface $uriGenerator - */ - public function __construct(HttpClient $httpClient, UriGeneratorInterface $uriGenerator) + public function __construct(protected HttpClient $httpClient, protected UriGeneratorInterface $uriGenerator) { - $this->httpClient = $httpClient; - $this->uriGenerator = $uriGenerator; } /** @@ -79,8 +67,6 @@ protected function authenticate($clientId, $secret, array $requestBody): array $response = $this->httpClient->sendRequest('POST', $uri, $headers, json_encode($requestBody)); - $responseBody = json_decode($response->getBody()->getContents(), true); - - return $responseBody; + return json_decode($response->getBody()->getContents(), true); } } diff --git a/src/Api/CategoryApi.php b/src/Api/CategoryApi.php index 8b2f64af..34e46ec7 100644 --- a/src/Api/CategoryApi.php +++ b/src/Api/CategoryApi.php @@ -21,28 +21,8 @@ class CategoryApi implements CategoryApiInterface public const CATEGORY_URI = 'api/rest/v1/categories/%s'; public const CATEGORIES_URI = 'api/rest/v1/categories'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ChannelApi.php b/src/Api/ChannelApi.php index 38bf2f8c..b77e088a 100644 --- a/src/Api/ChannelApi.php +++ b/src/Api/ChannelApi.php @@ -21,28 +21,8 @@ class ChannelApi implements ChannelApiInterface public const CHANNELS_URI = 'api/rest/v1/channels'; public const CHANNEL_URI = 'api/rest/v1/channels/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/CurrencyApi.php b/src/Api/CurrencyApi.php index 28b3c33d..6646e843 100644 --- a/src/Api/CurrencyApi.php +++ b/src/Api/CurrencyApi.php @@ -20,28 +20,8 @@ class CurrencyApi implements CurrencyApiInterface public const CURRENCY_URI = 'api/rest/v1/currencies/%s'; public const CURRENCIES_URI = 'api/rest/v1/currencies'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/FamilyApi.php b/src/Api/FamilyApi.php index 72b24729..8d22856b 100644 --- a/src/Api/FamilyApi.php +++ b/src/Api/FamilyApi.php @@ -21,28 +21,8 @@ class FamilyApi implements FamilyApiInterface public const FAMILIES_URI = 'api/rest/v1/families'; public const FAMILY_URI = 'api/rest/v1/families/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/FamilyVariantApi.php b/src/Api/FamilyVariantApi.php index 0cfbaa3a..0d6e4bc2 100644 --- a/src/Api/FamilyVariantApi.php +++ b/src/Api/FamilyVariantApi.php @@ -21,28 +21,8 @@ class FamilyVariantApi implements FamilyVariantApiInterface public const FAMILY_VARIANT_URI = 'api/rest/v1/families/%s/variants/%s'; public const FAMILY_VARIANTS_URI = 'api/rest/v1/families/%s/variants'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/LocaleApi.php b/src/Api/LocaleApi.php index b150a050..e3588e1a 100644 --- a/src/Api/LocaleApi.php +++ b/src/Api/LocaleApi.php @@ -20,28 +20,8 @@ class LocaleApi implements LocaleApiInterface public const LOCALES_URI = 'api/rest/v1/locales'; public const LOCALE_URI = 'api/rest/v1/locales/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/MeasureFamilyApi.php b/src/Api/MeasureFamilyApi.php index a23fa8e0..50b518f2 100644 --- a/src/Api/MeasureFamilyApi.php +++ b/src/Api/MeasureFamilyApi.php @@ -20,28 +20,8 @@ class MeasureFamilyApi implements MeasureFamilyApiInterface public const MEASURE_FAMILY_URI = 'api/rest/v1/measure-families/%s'; public const MEASURE_FAMILIES_URI = 'api/rest/v1/measure-families'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/MeasurementFamilyApi.php b/src/Api/MeasurementFamilyApi.php index 348c0631..3a92fe15 100644 --- a/src/Api/MeasurementFamilyApi.php +++ b/src/Api/MeasurementFamilyApi.php @@ -15,15 +15,8 @@ class MeasurementFamilyApi implements MeasurementFamilyApiInterface { public const MEASUREMENT_FAMILIES_URI = 'api/rest/v1/measurement-families'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** - * @param ResourceClientInterface $resourceClient - */ - public function __construct(ResourceClientInterface $resourceClient) + public function __construct(protected ResourceClientInterface $resourceClient) { - $this->resourceClient = $resourceClient; } /** diff --git a/src/Api/Operation/UpsertableResourceListInterface.php b/src/Api/Operation/UpsertableResourceListInterface.php index 89f1323f..0f19fae4 100644 --- a/src/Api/Operation/UpsertableResourceListInterface.php +++ b/src/Api/Operation/UpsertableResourceListInterface.php @@ -23,5 +23,5 @@ interface UpsertableResourceListInterface * * @return \Traversable returns an iterable object, each entry corresponding to the response of the upserted resource */ - public function upsertList($resources): \Traversable; + public function upsertList(array|StreamInterface $resources): \Traversable; } diff --git a/src/Api/ProductApi.php b/src/Api/ProductApi.php index c7d45fd1..87b5e792 100644 --- a/src/Api/ProductApi.php +++ b/src/Api/ProductApi.php @@ -21,28 +21,8 @@ class ProductApi implements ProductApiInterface public const PRODUCTS_URI = 'api/rest/v1/products'; public const PRODUCT_URI = 'api/rest/v1/products/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ProductDraftApi.php b/src/Api/ProductDraftApi.php index e9ac99e6..ef0e1e21 100644 --- a/src/Api/ProductDraftApi.php +++ b/src/Api/ProductDraftApi.php @@ -20,23 +20,8 @@ class ProductDraftApi implements ProductDraftApiInterface public const PRODUCT_DRAFT_URI = '/api/rest/v1/products/%s/draft'; public const PRODUCT_PROPOSAL_URI = '/api/rest/v1/products/%s/proposal'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ProductDraftUuidApi.php b/src/Api/ProductDraftUuidApi.php index 75c1c9d8..4603c417 100644 --- a/src/Api/ProductDraftUuidApi.php +++ b/src/Api/ProductDraftUuidApi.php @@ -17,18 +17,8 @@ class ProductDraftUuidApi implements ProductDraftUuidApiInterface public const PRODUCT_DRAFT_UUID_URI = '/api/rest/v1/products-uuid/%s/draft'; public const PRODUCT_PROPOSAL_UUID_URI = '/api/rest/v1/products-uuid/%s/proposal'; - protected ResourceClientInterface $resourceClient; - protected PageFactoryInterface $pageFactory; - protected ResourceCursorFactoryInterface $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ProductMediaFileApi.php b/src/Api/ProductMediaFileApi.php index ecb84480..230d836b 100644 --- a/src/Api/ProductMediaFileApi.php +++ b/src/Api/ProductMediaFileApi.php @@ -25,34 +25,8 @@ class ProductMediaFileApi implements MediaFileApiInterface public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/media-files/%s/download'; public const MEDIA_FILE_URI_CODE_REGEX = '~/api/rest/v1/media\-files/(?P.*)$~'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** @var FileSystemInterface */ - private $fileSystem; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - * @param FileSystemInterface $fileSystem - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory, - FileSystemInterface $fileSystem - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; - $this->fileSystem = $fileSystem; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory, private FileSystemInterface $fileSystem) + { } /** @@ -121,8 +95,6 @@ public function download(string $code): ResponseInterface /** * Extracts the code of a media-file from a creation response. * - * @param ResponseInterface $response - * * @throws RuntimeException if unable to extract the code * * @return mixed diff --git a/src/Api/ProductModelApi.php b/src/Api/ProductModelApi.php index 1e03f615..6fc81b7c 100644 --- a/src/Api/ProductModelApi.php +++ b/src/Api/ProductModelApi.php @@ -21,28 +21,8 @@ class ProductModelApi implements ProductModelApiInterface public const PRODUCT_MODEL_URI = 'api/rest/v1/product-models/%s'; public const PRODUCT_MODELS_URI = 'api/rest/v1/product-models'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - /** - * @param ResourceClientInterface $resourceClient - * @param PageFactoryInterface $pageFactory - * @param ResourceCursorFactoryInterface $cursorFactory - */ - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ProductModelDraftApi.php b/src/Api/ProductModelDraftApi.php index 65b5de03..45e30fa6 100644 --- a/src/Api/ProductModelDraftApi.php +++ b/src/Api/ProductModelDraftApi.php @@ -20,23 +20,8 @@ class ProductModelDraftApi implements ProductModelDraftApiInterface public const PRODUCT_MODEL_DRAFT_URI = '/api/rest/v1/product-models/%s/draft'; public const PRODUCT_MODEL_PROPOSAL_URI = '/api/rest/v1/product-models/%s/proposal'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ProductUuidApi.php b/src/Api/ProductUuidApi.php index 9f101f8e..2bf2dd40 100644 --- a/src/Api/ProductUuidApi.php +++ b/src/Api/ProductUuidApi.php @@ -20,18 +20,8 @@ class ProductUuidApi implements ProductUuidApiInterface public const PRODUCTS_UUID_URI = 'api/rest/v1/products-uuid'; public const PRODUCT_UUID_URI = 'api/rest/v1/products-uuid/%s'; - protected ResourceClientInterface $resourceClient; - protected PageFactoryInterface $pageFactory; - protected ResourceCursorFactoryInterface $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } public function listPerPage(int $limit = 100, bool $withCount = false, array $queryParameters = []): PageInterface { diff --git a/src/Api/PublishedProductApi.php b/src/Api/PublishedProductApi.php index ee6955e3..c71c1b88 100644 --- a/src/Api/PublishedProductApi.php +++ b/src/Api/PublishedProductApi.php @@ -22,23 +22,8 @@ class PublishedProductApi implements PublishedProductApiInterface public const PUBLISHED_PRODUCTS_URI = 'api/rest/v1/published-products'; public const PUBLISHED_PRODUCT_URI = 'api/rest/v1/published-products/%s'; - /** @var ResourceClientInterface */ - protected $resourceClient; - - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - protected $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ReferenceEntityApi.php b/src/Api/ReferenceEntityApi.php index 754fb964..5d5fdc49 100644 --- a/src/Api/ReferenceEntityApi.php +++ b/src/Api/ReferenceEntityApi.php @@ -19,23 +19,8 @@ class ReferenceEntityApi implements ReferenceEntityApiInterface public const REFERENCE_ENTITY_URI = 'api/rest/v1/reference-entities/%s'; public const REFERENCE_ENTITIES_URI= 'api/rest/v1/reference-entities'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Api/ReferenceEntityAttributeApi.php b/src/Api/ReferenceEntityAttributeApi.php index 468b4a41..6d8bb499 100644 --- a/src/Api/ReferenceEntityAttributeApi.php +++ b/src/Api/ReferenceEntityAttributeApi.php @@ -16,12 +16,8 @@ class ReferenceEntityAttributeApi implements ReferenceEntityAttributeApiInterfac public const REFERENCE_ENTITY_ATTRIBUTE_URI = 'api/rest/v1/reference-entities/%s/attributes/%s'; public const REFERENCE_ENTITY_ATTRIBUTES_URI = 'api/rest/v1/reference-entities/%s/attributes'; - /** @var ResourceClientInterface */ - private $resourceClient; - - public function __construct(ResourceClientInterface $resourceClient) + public function __construct(private ResourceClientInterface $resourceClient) { - $this->resourceClient = $resourceClient; } /** diff --git a/src/Api/ReferenceEntityAttributeOptionApi.php b/src/Api/ReferenceEntityAttributeOptionApi.php index 0433715e..8db4b88a 100644 --- a/src/Api/ReferenceEntityAttributeOptionApi.php +++ b/src/Api/ReferenceEntityAttributeOptionApi.php @@ -16,12 +16,8 @@ class ReferenceEntityAttributeOptionApi implements ReferenceEntityAttributeOptio public const REFERENCE_ENTITY_ATTRIBUTE_OPTION_URI = 'api/rest/v1/reference-entities/%s/attributes/%s/options/%s'; public const REFERENCE_ENTITY_ATTRIBUTE_OPTIONS_URI = 'api/rest/v1/reference-entities/%s/attributes/%s/options'; - /** @var ResourceClientInterface */ - private $resourceClient; - - public function __construct(ResourceClientInterface $resourceClient) + public function __construct(private ResourceClientInterface $resourceClient) { - $this->resourceClient = $resourceClient; } /** diff --git a/src/Api/ReferenceEntityMediaFileApi.php b/src/Api/ReferenceEntityMediaFileApi.php index 4542b39d..2c87c175 100644 --- a/src/Api/ReferenceEntityMediaFileApi.php +++ b/src/Api/ReferenceEntityMediaFileApi.php @@ -19,16 +19,8 @@ class ReferenceEntityMediaFileApi implements ReferenceEntityMediaFileApiInterfac public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/reference-entities-media-files/%s'; public const MEDIA_FILE_CREATE_URI = 'api/rest/v1/reference-entities-media-files'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var FileSystemInterface */ - private $fileSystem; - - public function __construct(ResourceClientInterface $resourceClient, FileSystemInterface $fileSystem) + public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) { - $this->resourceClient = $resourceClient; - $this->fileSystem = $fileSystem; } /** @@ -63,11 +55,7 @@ public function create($mediaFile): string /** * Extracts the code of a media-file from a creation response. * - * @param ResponseInterface $response - * * @throws RuntimeException if unable to extract the code - * - * @return string */ private function extractCodeFromCreationResponse(ResponseInterface $response): string { diff --git a/src/Api/ReferenceEntityRecordApi.php b/src/Api/ReferenceEntityRecordApi.php index 7d9ed517..d46e44f9 100644 --- a/src/Api/ReferenceEntityRecordApi.php +++ b/src/Api/ReferenceEntityRecordApi.php @@ -19,23 +19,8 @@ class ReferenceEntityRecordApi implements ReferenceEntityRecordApiInterface public const REFERENCE_ENTITY_RECORD_URI = 'api/rest/v1/reference-entities/%s/records/%s'; public const REFERENCE_ENTITY_RECORDS_URI = 'api/rest/v1/reference-entities/%s/records'; - /** @var ResourceClientInterface */ - private $resourceClient; - - /** @var PageFactoryInterface */ - private $pageFactory; - - /** @var ResourceCursorFactoryInterface */ - private $cursorFactory; - - public function __construct( - ResourceClientInterface $resourceClient, - PageFactoryInterface $pageFactory, - ResourceCursorFactoryInterface $cursorFactory - ) { - $this->resourceClient = $resourceClient; - $this->pageFactory = $pageFactory; - $this->cursorFactory = $cursorFactory; + public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) + { } /** diff --git a/src/Cache/CacheInterface.php b/src/Cache/CacheInterface.php index 3754bc34..767a202c 100644 --- a/src/Cache/CacheInterface.php +++ b/src/Cache/CacheInterface.php @@ -16,8 +16,6 @@ public function get(string $key): ?array; /** * @param string $key Key of the cached resource * @param mixed $value The cached resource - * - * @return void */ - public function set(string $key, $value): void; + public function set(string $key, mixed $value): void; } diff --git a/src/Cache/LRUCache.php b/src/Cache/LRUCache.php index ba7f50df..f1992174 100644 --- a/src/Cache/LRUCache.php +++ b/src/Cache/LRUCache.php @@ -6,15 +6,13 @@ class LRUCache implements CacheInterface { - private int $maxItems; private array $items = []; /** * @param int $maxItems Maximum number of allowed cache items. */ - public function __construct(int $maxItems = 100) + public function __construct(private int $maxItems = 100) { - $this->maxItems = $maxItems; } /** @@ -46,10 +44,8 @@ public function set(string $key, $value): void if ($diff <= 0) { return; } - - reset($this->items); for ($i = 0; $i < $diff; $i++) { - unset($this->items[key($this->items)]); + unset($this->items[array_key_first($this->items)]); next($this->items); } } diff --git a/src/Client/AuthenticatedHttpClient.php b/src/Client/AuthenticatedHttpClient.php index 58b6c381..b9ce7e04 100644 --- a/src/Client/AuthenticatedHttpClient.php +++ b/src/Client/AuthenticatedHttpClient.php @@ -22,23 +22,8 @@ */ class AuthenticatedHttpClient implements HttpClientInterface { - /** @var HttpClient */ - protected $basicHttpClient; - - /** @var AuthenticationApiInterface */ - protected $authenticationApi; - - /** @var Authentication */ - protected $authentication; - - public function __construct( - HttpClient $basicHttpClient, - AuthenticationApiInterface $authenticationApi, - Authentication $authentication - ) { - $this->basicHttpClient = $basicHttpClient; - $this->authenticationApi = $authenticationApi; - $this->authentication = $authentication; + public function __construct(protected HttpClient $basicHttpClient, protected AuthenticationApiInterface $authenticationApi, protected Authentication $authentication) + { } /** @@ -84,7 +69,7 @@ private function renewTokens(UnauthorizedHttpException $unauthorizedHttpExceptio $this->authentication->getSecret(), $this->authentication->getRefreshToken() ); - } catch (UnprocessableEntityHttpException $e) { + } catch (UnprocessableEntityHttpException) { throw $unauthorizedHttpException; } } diff --git a/src/Client/CachedResourceClient.php b/src/Client/CachedResourceClient.php index 684a639c..bd0f9016 100644 --- a/src/Client/CachedResourceClient.php +++ b/src/Client/CachedResourceClient.php @@ -13,15 +13,8 @@ */ class CachedResourceClient implements ResourceClientInterface { - private ResourceClientInterface $resourceClient; - private CacheInterface $cache; - - public function __construct( - ResourceClientInterface $resourceClient, - CacheInterface $cache - ) { - $this->resourceClient = $resourceClient; - $this->cache = $cache; + public function __construct(private ResourceClientInterface $resourceClient, private CacheInterface $cache) + { } /** diff --git a/src/Client/HttpClient.php b/src/Client/HttpClient.php index 20a3a219..58e86f69 100644 --- a/src/Client/HttpClient.php +++ b/src/Client/HttpClient.php @@ -29,24 +29,15 @@ class HttpClient implements HttpClientInterface public const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; public const HTTP_UNPROCESSABLE_ENTITY = 422; public const HTTP_TOO_MANY_REQUESTS = 429; - - protected ClientInterface $httpClient; - protected RequestFactoryInterface $requestFactory; protected HttpExceptionHandler $httpExceptionHandler; - private StreamFactoryInterface $streamFactory; - private Options $options; public function __construct( - ClientInterface $httpClient, - RequestFactoryInterface $requestFactory, - StreamFactoryInterface $streamFactory, - Options $options + protected ClientInterface $httpClient, + protected RequestFactoryInterface $requestFactory, + private StreamFactoryInterface $streamFactory, + private Options $options ) { - $this->httpClient = $httpClient; - $this->requestFactory = $requestFactory; - $this->streamFactory = $streamFactory; $this->httpExceptionHandler = new HttpExceptionHandler(); - $this->options = $options; } /** @@ -74,8 +65,7 @@ public function sendRequest(string $httpMethod, $uri, array $headers = [], $body } $response = $this->httpClient->sendRequest($request); - $response = $this->httpExceptionHandler->transformResponseToException($request, $response); - return $response; + return $this->httpExceptionHandler->transformResponseToException($request, $response); } } diff --git a/src/Client/HttpExceptionHandler.php b/src/Client/HttpExceptionHandler.php index 85af429c..ff6a0602 100644 --- a/src/Client/HttpExceptionHandler.php +++ b/src/Client/HttpExceptionHandler.php @@ -94,10 +94,6 @@ public function transformResponseToException( /** * Returns the response message, or the reason phrase if there is none. - * - * @param ResponseInterface $response - * - * @return string */ protected function getResponseMessage(ResponseInterface $response): string { diff --git a/src/Client/Options.php b/src/Client/Options.php index 2ad7c006..880d861a 100644 --- a/src/Client/Options.php +++ b/src/Client/Options.php @@ -8,11 +8,8 @@ class Options { - private array $options; - - private function __construct(array $options) + private function __construct(private array $options) { - $this->options = $options; } public static function fromArray(array $options): self diff --git a/src/Client/ResourceClient.php b/src/Client/ResourceClient.php index 5aef3ffe..a6db5fe4 100644 --- a/src/Client/ResourceClient.php +++ b/src/Client/ResourceClient.php @@ -21,21 +21,8 @@ */ class ResourceClient implements ResourceClientInterface { - protected HttpClientInterface $httpClient; - protected UriGeneratorInterface $uriGenerator; - protected MultipartStreamBuilderFactory $multipartStreamBuilderFactory; - protected UpsertResourceListResponseFactory $upsertListResponseFactory; - - public function __construct( - HttpClientInterface $httpClient, - UriGeneratorInterface $uriGenerator, - MultipartStreamBuilderFactory $multipartStreamBuilderFactory, - UpsertResourceListResponseFactory $upsertListResponseFactory - ) { - $this->httpClient = $httpClient; - $this->uriGenerator = $uriGenerator; - $this->multipartStreamBuilderFactory = $multipartStreamBuilderFactory; - $this->upsertListResponseFactory = $upsertListResponseFactory; + public function __construct(protected HttpClientInterface $httpClient, protected UriGeneratorInterface $uriGenerator, protected MultipartStreamBuilderFactory $multipartStreamBuilderFactory, protected UpsertResourceListResponseFactory $upsertListResponseFactory) + { } /** diff --git a/src/Exception/HttpException.php b/src/Exception/HttpException.php index b36fb225..e0d1d659 100644 --- a/src/Exception/HttpException.php +++ b/src/Exception/HttpException.php @@ -14,19 +14,14 @@ */ class HttpException extends RuntimeException { - /** @var RequestInterface */ - protected $request; - /** @var ResponseInterface */ protected $response; - public function __construct(string $message, RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null) + public function __construct(string $message, protected RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null) { $message .= ' ' . $this->getAdditionalInformationMessage(); parent::__construct($message, $response->getStatusCode(), $previous); - - $this->request = $request; $this->response = $response; } diff --git a/src/Exception/UploadAssetReferenceFileErrorException.php b/src/Exception/UploadAssetReferenceFileErrorException.php index 15147241..a88f10d5 100644 --- a/src/Exception/UploadAssetReferenceFileErrorException.php +++ b/src/Exception/UploadAssetReferenceFileErrorException.php @@ -14,18 +14,12 @@ */ class UploadAssetReferenceFileErrorException extends RuntimeException { - /** @var array */ - private $errors; - /** * @param string $message - * @param array $errors */ - public function __construct($message, array $errors) + public function __construct($message, private array $errors) { parent::__construct($message); - - $this->errors = $errors; } public function getErrors(): array diff --git a/src/MultipartStream/MultipartStreamBuilder.php b/src/MultipartStream/MultipartStreamBuilder.php index c8ede8fe..599344fe 100644 --- a/src/MultipartStream/MultipartStreamBuilder.php +++ b/src/MultipartStream/MultipartStreamBuilder.php @@ -14,24 +14,19 @@ */ class MultipartStreamBuilder { - /** @var StreamFactoryInterface */ - private $streamFactory; - /** @var MimetypeHelper */ private $mimetypeHelper; - /** @var string */ - private $boundary; + private ?string $boundary = null; /** * @var array Element where each Element is an array with keys ['contents', 'headers', 'filename'] */ - private $data = []; + private array $data = []; - public function __construct(StreamFactoryInterface $streamFactory) + public function __construct(private StreamFactoryInterface $streamFactory) { - $this->streamFactory = $streamFactory; } /** @@ -68,7 +63,7 @@ public function addResource(string $name, $resource, array $options = []) if (empty($options['filename'])) { $options['filename'] = null; $uri = $stream->getMetadata('uri'); - if (substr($uri, 0, 6) !== 'php://') { + if (!str_starts_with($uri, 'php://')) { $options['filename'] = $uri; } } @@ -131,25 +126,19 @@ private function prepareHeaders($name, StreamInterface $stream, $filename, array } // Set a default content-length header if one was not provided - if (!$this->hasHeader($headers, 'content-length')) { - if ($length = $stream->getSize()) { - $headers['Content-Length'] = (string) $length; - } + if (!$this->hasHeader($headers, 'content-length') && ($length = $stream->getSize())) { + $headers['Content-Length'] = (string) $length; } // Set a default Content-Type if one was not provided - if (!$this->hasHeader($headers, 'content-type') && $hasFilename) { - if ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename)) { - $headers['Content-Type'] = $type; - } + if (!$this->hasHeader($headers, 'content-type') && $hasFilename && ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename))) { + $headers['Content-Type'] = $type; } } /** * Get the headers formatted for the HTTP message. * - * @param array $headers - * * @return string */ private function getHeaders(array $headers) @@ -165,9 +154,7 @@ private function getHeaders(array $headers) /** * Check if header exist. * - * @param array $headers * @param string $key case insensitive - * * @return bool */ private function hasHeader(array $headers, $key) @@ -223,8 +210,6 @@ private function getMimetypeHelper() /** * If you have custom file extension you may overwrite the default MimetypeHelper with your own. * - * @param MimetypeHelper $mimetypeHelper - * * @return MultipartStreamBuilder */ public function setMimetypeHelper(MimetypeHelper $mimetypeHelper) diff --git a/src/Pagination/Page.php b/src/Pagination/Page.php index a4a8cb28..887ba87e 100644 --- a/src/Pagination/Page.php +++ b/src/Pagination/Page.php @@ -13,43 +13,8 @@ */ class Page implements PageInterface { - /** @var PageFactoryInterface */ - protected $pageFactory; - - /** @var HttpClientInterface */ - protected $httpClient; - - /** @var string */ - protected $firstLink; - - /** @var string */ - protected $previousLink; - - /** @var string */ - protected $nextLink; - - /** @var integer */ - protected $count; - - /** @var array */ - protected $items; - - public function __construct( - PageFactoryInterface $pageFactory, - HttpClientInterface $httpClient, - string $firstLink, - ?string$previousLink, - ?string $nextLink, - ?int $count, - array $items - ) { - $this->pageFactory = $pageFactory; - $this->httpClient = $httpClient; - $this->firstLink = $firstLink; - $this->previousLink = $previousLink; - $this->nextLink = $nextLink; - $this->count = $count; - $this->items = $items; + public function __construct(protected PageFactoryInterface $pageFactory, protected HttpClientInterface $httpClient, protected string $firstLink, protected ?string$previousLink, protected ?string $nextLink, protected ?int $count, protected array $items) + { } /** diff --git a/src/Pagination/PageFactory.php b/src/Pagination/PageFactory.php index 5ba2e826..ad469ec0 100644 --- a/src/Pagination/PageFactory.php +++ b/src/Pagination/PageFactory.php @@ -13,12 +13,8 @@ */ class PageFactory implements PageFactoryInterface { - /** @var HttpClientInterface */ - protected $httpClient; - - public function __construct(HttpClientInterface $httpClient) + public function __construct(protected HttpClientInterface $httpClient) { - $this->httpClient = $httpClient; } /** diff --git a/src/Pagination/ResourceCursor.php b/src/Pagination/ResourceCursor.php index 15131e5b..4f269a0e 100644 --- a/src/Pagination/ResourceCursor.php +++ b/src/Pagination/ResourceCursor.php @@ -12,17 +12,12 @@ class ResourceCursor implements ResourceCursorInterface { protected PageInterface $currentPage; - protected PageInterface $firstPage; - /** @var null|int */ - protected $pageSize; protected int $currentIndex = 0; protected int $totalIndex = 0; - public function __construct(?int $pageSize, PageInterface $firstPage) + public function __construct(protected ?int $pageSize, protected PageInterface $firstPage) { - $this->firstPage = $firstPage; $this->currentPage = $firstPage; - $this->pageSize = $pageSize; } /** diff --git a/src/Routing/UriGenerator.php b/src/Routing/UriGenerator.php index 9876dab2..783cb3f4 100644 --- a/src/Routing/UriGenerator.php +++ b/src/Routing/UriGenerator.php @@ -49,8 +49,6 @@ public function generate($path, array $uriParameters = [], array $queryParameter /** * Transforms boolean query parameters as string 'true' or 'false' instead of 0 or 1. * - * @param array $queryParameters - * * @return array */ protected function booleanQueryParametersAsString(array $queryParameters) diff --git a/src/Search/SearchBuilder.php b/src/Search/SearchBuilder.php index 22e411fc..05d3f161 100644 --- a/src/Search/SearchBuilder.php +++ b/src/Search/SearchBuilder.php @@ -24,8 +24,6 @@ class SearchBuilder * @param string $operator operator of the filter. * @param mixed|null $value value of the filter. Should not be defined for certain specifics operators. * @param array $options optionals parameters to apply to the filter (as scope or locale). - * - * @return SearchBuilder */ public function addFilter(string $property, string $operator, $value = null, array $options = []): self { diff --git a/src/Stream/LineStreamReader.php b/src/Stream/LineStreamReader.php index 4da3a989..87856c27 100644 --- a/src/Stream/LineStreamReader.php +++ b/src/Stream/LineStreamReader.php @@ -16,8 +16,6 @@ class LineStreamReader /** * Gets the next line of a stream. * - * @param StreamInterface $stream - * * @return string|null returns the line, or null if the stream is not readable or at the end */ public function getNextLine(StreamInterface $stream): ?string diff --git a/src/Stream/MultipartStreamBuilderFactory.php b/src/Stream/MultipartStreamBuilderFactory.php index c709a608..021bc885 100644 --- a/src/Stream/MultipartStreamBuilderFactory.php +++ b/src/Stream/MultipartStreamBuilderFactory.php @@ -14,12 +14,8 @@ */ class MultipartStreamBuilderFactory { - /** @var StreamFactoryInterface */ - protected $streamFactory; - - public function __construct(StreamFactoryInterface $streamFactory) + public function __construct(protected StreamFactoryInterface $streamFactory) { - $this->streamFactory = $streamFactory; } public function create(): MultipartStreamBuilder diff --git a/src/Stream/UpsertResourceListResponse.php b/src/Stream/UpsertResourceListResponse.php index a50df2e9..6704739a 100644 --- a/src/Stream/UpsertResourceListResponse.php +++ b/src/Stream/UpsertResourceListResponse.php @@ -18,22 +18,14 @@ */ class UpsertResourceListResponse implements \Iterator { - /** @var StreamInterface */ - protected $bodyStream; - - /** @var LineStreamReader */ - protected $streamReader; - /** @var int */ protected $lineNumber = 1; /** @var string */ protected $line; - public function __construct(StreamInterface $bodyStream, LineStreamReader $streamReader) + public function __construct(protected StreamInterface $bodyStream, protected LineStreamReader $streamReader) { - $this->bodyStream = $bodyStream; - $this->streamReader = $streamReader; } /** diff --git a/tests/Api/AssetFamily/ListAllAssetFamiliesIntegration.php b/tests/Api/AssetFamily/ListAllAssetFamiliesIntegration.php index a95103e6..a60bed80 100644 --- a/tests/Api/AssetFamily/ListAllAssetFamiliesIntegration.php +++ b/tests/Api/AssetFamily/ListAllAssetFamiliesIntegration.php @@ -15,7 +15,7 @@ class ListAllAssetFamiliesIntegration extends ApiTestCase public function test_list_per_page() { $this->server->setResponseOfPath( - '/' . sprintf(AssetFamilyApi::ASSET_FAMILIES_URI), + '/' . AssetFamilyApi::ASSET_FAMILIES_URI, new ResponseStack( new Response($this->getFirstPage(), [], 200), new Response($this->getSecondPage(), [], 200) From 2427e6c0d6adc8a0338866e5fd4194117bfd82d6 Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Mon, 7 Nov 2022 11:22:27 +0100 Subject: [PATCH 7/8] chore(API-1925): Ignore phpspec tests for code style check --- ecs.php | 1 - 1 file changed, 1 deletion(-) diff --git a/ecs.php b/ecs.php index 4d7bfc8b..4b5b94d4 100644 --- a/ecs.php +++ b/ecs.php @@ -10,7 +10,6 @@ $ecsConfig->paths([ __DIR__ . '/src', __DIR__ . '/tests', - __DIR__ . '/spec' ]); $ecsConfig->sets([SetList::PSR_12]); From f12cd6f2186a9325f61e77ec20381ac1d3661961 Mon Sep 17 00:00:00 2001 From: LevFlavien Date: Mon, 7 Nov 2022 11:28:33 +0100 Subject: [PATCH 8/8] refact(API-1925): Run ECS --- src/AkeneoPimClient.php | 42 ++++++++++++++++- src/AkeneoPimClientBuilder.php | 22 ++++++--- src/Api/AppCatalog/AppCatalogApi.php | 7 ++- src/Api/AppCatalog/AppCatalogProductApi.php | 7 ++- src/Api/AssetApi.php | 7 ++- src/Api/AssetCategoryApi.php | 7 ++- src/Api/AssetManager/AssetApi.php | 9 ++-- src/Api/AssetManager/AssetAttributeApi.php | 5 ++- .../AssetManager/AssetAttributeOptionApi.php | 5 ++- src/Api/AssetManager/AssetFamilyApi.php | 9 ++-- src/Api/AssetManager/AssetMediaFileApi.php | 6 ++- src/Api/AssetReferenceFileApi.php | 12 +++-- src/Api/AssetTagApi.php | 7 ++- src/Api/AssetVariationFileApi.php | 6 ++- src/Api/AssociationTypeApi.php | 7 ++- src/Api/AttributeApi.php | 7 ++- src/Api/AttributeGroupApi.php | 7 ++- src/Api/AttributeOptionApi.php | 7 ++- src/Api/AuthenticationApi.php | 14 +++--- src/Api/CategoryApi.php | 7 ++- src/Api/ChannelApi.php | 7 ++- src/Api/CurrencyApi.php | 7 ++- src/Api/FamilyApi.php | 7 ++- src/Api/FamilyVariantApi.php | 7 ++- src/Api/LocaleApi.php | 7 ++- src/Api/MeasureFamilyApi.php | 7 ++- src/Api/MeasurementFamilyApi.php | 5 ++- src/Api/ProductApi.php | 7 ++- src/Api/ProductDraftApi.php | 7 ++- src/Api/ProductDraftUuidApi.php | 7 ++- src/Api/ProductMediaFileApi.php | 8 +++- src/Api/ProductModelApi.php | 7 ++- src/Api/ProductModelDraftApi.php | 7 ++- src/Api/ProductUuidApi.php | 7 ++- src/Api/PublishedProductApi.php | 7 ++- src/Api/ReferenceEntityApi.php | 9 ++-- src/Api/ReferenceEntityAttributeApi.php | 5 ++- src/Api/ReferenceEntityAttributeOptionApi.php | 5 ++- src/Api/ReferenceEntityMediaFileApi.php | 6 ++- src/Api/ReferenceEntityRecordApi.php | 7 ++- src/Cache/LRUCache.php | 5 ++- src/Client/AuthenticatedHttpClient.php | 13 +++--- src/Client/CachedResourceClient.php | 17 ++++--- src/Client/Options.php | 5 ++- src/Client/ResourceClient.php | 8 +++- src/Client/ResourceClientInterface.php | 8 +++- src/Exception/HttpException.php | 8 +++- ...UploadAssetReferenceFileErrorException.php | 6 ++- .../MultipartStreamBuilder.php | 15 ++++--- src/Pagination/Page.php | 11 ++++- src/Pagination/PageFactory.php | 5 ++- src/Pagination/ResourceCursor.php | 6 ++- src/Search/SearchBuilder.php | 2 +- src/Stream/LineStreamReader.php | 2 +- src/Stream/MultipartStreamBuilderFactory.php | 5 ++- src/Stream/UpsertResourceListResponse.php | 6 ++- tests/Api/ApiTestCase.php | 2 +- .../CreateAppCatalogIntegration.php | 3 +- .../DeleteAppCatalogIntegration.php | 5 ++- .../AppCatalog/GetAppCatalogIntegration.php | 3 +- .../AppCatalog/ListAppCatalogIntegration.php | 1 + .../UpsertAppCatalogIntegration.php | 3 +- .../ListAppCatalogProductIntegration.php | 2 +- tests/Api/Asset/GetAssetIntegration.php | 4 +- tests/Api/Asset/ListAllAssetsIntegration.php | 2 +- tests/Api/Asset/UpsertAssetIntegration.php | 2 +- .../Api/Asset/UpsertListAssetIntegration.php | 2 +- .../GetAssetFamilyAttributeIntegration.php | 4 +- .../UpsertAssetFamilyAttributeIntegration.php | 7 ++- ...tAssetFamilyAttributeOptionIntegration.php | 4 +- ...tAssetFamilyAttributeOptionIntegration.php | 7 ++- .../AssetFamily/GetAssetFamilyIntegration.php | 4 +- .../UpsertAssetFamilyIntegration.php | 2 +- .../DownloadAssetReferenceFileIntegration.php | 16 +++++-- .../UploadAssetReferenceFileIntegration.php | 42 +++++++++++------ ...wnloadAssetVariationFileApiIntegration.php | 19 +++++--- ...UploadAssetVariationFileApiIntegration.php | 39 +++++++++++----- tests/Api/CreateProductMediaFileTest.php | 12 ++--- tests/Api/CreateProductTest.php | 45 +++++++++++-------- tests/Api/DeleteProductModelTest.php | 2 +- tests/Api/DeleteProductTest.php | 2 +- tests/Api/DownloadProductMediaFileTest.php | 2 +- tests/Api/GetProductTest.php | 4 +- tests/Api/ListPerPageProductTest.php | 17 +++++-- .../GetProductDraftUuidIntegration.php | 4 +- .../CreateProductUuidIntegration.php | 4 +- .../DeleteProductUuidIntegration.php | 2 +- .../ProductUuid/GetProductUuidIntegration.php | 4 +- .../ListPerPageProductUuidIntegration.php | 19 +++++--- .../UpsertListProductUuidIntegration.php | 2 +- .../UpsertProductUuidIntegration.php | 9 ++-- .../GetReferenceEntityIntegration.php | 4 +- .../ListAllReferenceEntitiesIntegration.php | 4 +- .../UpsertReferenceEntityIntegration.php | 2 +- .../GetReferenceEntityRecordIntegration.php | 4 +- ...stAllReferenceEntityRecordsIntegration.php | 4 +- ...rtListReferenceEntityRecordIntegration.php | 14 +++--- ...UpsertReferenceEntityRecordIntegration.php | 6 +-- tests/Api/UpsertListProductTest.php | 41 +++++++++-------- tests/Api/UpsertProductTest.php | 9 ++-- tests/Cache/AkeneoPimClientBuilderTest.php | 3 +- tests/Cache/LRUCacheTest.php | 2 +- tests/Client/CachedResourceClientTest.php | 4 +- 103 files changed, 563 insertions(+), 293 deletions(-) diff --git a/src/AkeneoPimClient.php b/src/AkeneoPimClient.php index 2ccbd331..9ee84f13 100644 --- a/src/AkeneoPimClient.php +++ b/src/AkeneoPimClient.php @@ -50,8 +50,46 @@ */ class AkeneoPimClient implements AkeneoPimClientInterface { - public function __construct(protected Authentication $authentication, protected ProductApiInterface $productApi, protected CategoryApiInterface $categoryApi, protected AttributeApiInterface $attributeApi, protected AttributeOptionApiInterface $attributeOptionApi, protected AttributeGroupApiInterface $attributeGroupApi, protected FamilyApiInterface $familyApi, protected MediaFileApiInterface $productMediaFileApi, protected LocaleApiInterface $localeApi, protected ChannelApiInterface $channelApi, protected CurrencyApiInterface $currencyApi, protected MeasureFamilyApiInterface $measureFamilyApi, private MeasurementFamilyApiInterface $measurementFamilyApi, protected AssociationTypeApiInterface $associationTypeApi, protected FamilyVariantApiInterface $familyVariantApi, protected ProductModelApiInterface $productModelApi, private ProductModelDraftApiInterface $productModelDraftApi, private PublishedProductApiInterface $publishedProductApi, private ProductDraftApiInterface $productDraftApi, private AssetApiInterface $assetApi, private AssetCategoryApiInterface $assetCategoryApi, private AssetTagApiInterface $assetTagApi, private AssetReferenceFileApiInterface $assetReferenceFileApi, private AssetVariationFileApiInterface $assetVariationFileApi, private ReferenceEntityRecordApiInterface $referenceEntityRecordApi, private ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi, private ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi, private ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi, private ReferenceEntityApiInterface $referenceEntityApi, private AssetManagerApiInterface $assetManagerApi, private AssetFamilyApiInterface $assetFamilyApi, private AssetAttributeApiInterface $assetAttributeApi, private AssetAttributeOptionApiInterface $assetAttributeOptionApi, private AssetMediaFileApiInterface $assetMediaFileApi, private ProductUuidApiInterface $productUuidApi, private ProductDraftUuidApiInterface $productDraftUuidApi, private AppCatalogApiInterface $appCatalogApi, private AppCatalogProductApiInterface $appCatalogProductApi) - { + public function __construct( + protected Authentication $authentication, + protected ProductApiInterface $productApi, + protected CategoryApiInterface $categoryApi, + protected AttributeApiInterface $attributeApi, + protected AttributeOptionApiInterface $attributeOptionApi, + protected AttributeGroupApiInterface $attributeGroupApi, + protected FamilyApiInterface $familyApi, + protected MediaFileApiInterface $productMediaFileApi, + protected LocaleApiInterface $localeApi, + protected ChannelApiInterface $channelApi, + protected CurrencyApiInterface $currencyApi, + protected MeasureFamilyApiInterface $measureFamilyApi, + private MeasurementFamilyApiInterface $measurementFamilyApi, + protected AssociationTypeApiInterface $associationTypeApi, + protected FamilyVariantApiInterface $familyVariantApi, + protected ProductModelApiInterface $productModelApi, + private ProductModelDraftApiInterface $productModelDraftApi, + private PublishedProductApiInterface $publishedProductApi, + private ProductDraftApiInterface $productDraftApi, + private AssetApiInterface $assetApi, + private AssetCategoryApiInterface $assetCategoryApi, + private AssetTagApiInterface $assetTagApi, + private AssetReferenceFileApiInterface $assetReferenceFileApi, + private AssetVariationFileApiInterface $assetVariationFileApi, + private ReferenceEntityRecordApiInterface $referenceEntityRecordApi, + private ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi, + private ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi, + private ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi, + private ReferenceEntityApiInterface $referenceEntityApi, + private AssetManagerApiInterface $assetManagerApi, + private AssetFamilyApiInterface $assetFamilyApi, + private AssetAttributeApiInterface $assetAttributeApi, + private AssetAttributeOptionApiInterface $assetAttributeOptionApi, + private AssetMediaFileApiInterface $assetMediaFileApi, + private ProductUuidApiInterface $productUuidApi, + private ProductDraftUuidApiInterface $productDraftUuidApi, + private AppCatalogApiInterface $appCatalogApi, + private AppCatalogProductApiInterface $appCatalogProductApi + ) { } /** diff --git a/src/AkeneoPimClientBuilder.php b/src/AkeneoPimClientBuilder.php index b6081000..dd3ffa78 100644 --- a/src/AkeneoPimClientBuilder.php +++ b/src/AkeneoPimClientBuilder.php @@ -89,8 +89,10 @@ class AkeneoPimClientBuilder /** * @param string $baseUri Base uri to request the API */ - public function __construct(protected string $baseUri, array $options = []) - { + public function __construct( + protected string $baseUri, + array $options = [] + ) { $this->options = Options::fromArray($options); } @@ -142,8 +144,12 @@ public function setFileSystem(FileSystemInterface $fileSystem): self * @param string $username Username to use for the authentication * @param string $password Password associated to the username */ - public function buildAuthenticatedByPassword(string $clientId, string $secret, string $username, string $password): AkeneoPimClientInterface - { + public function buildAuthenticatedByPassword( + string $clientId, + string $secret, + string $username, + string $password + ): AkeneoPimClientInterface { $authentication = Authentication::fromPassword($clientId, $secret, $username, $password); return $this->buildAuthenticatedClient($authentication); @@ -164,8 +170,12 @@ public function buildAuthenticatedByAppToken(string $token): AkeneoPimClientInte * @param string $token Token to use for the authentication * @param string $refreshToken Token to use to refresh the access token */ - public function buildAuthenticatedByToken(string $clientId, string $secret, string $token, string $refreshToken): AkeneoPimClientInterface - { + public function buildAuthenticatedByToken( + string $clientId, + string $secret, + string $token, + string $refreshToken + ): AkeneoPimClientInterface { $authentication = Authentication::fromToken($clientId, $secret, $token, $refreshToken); return $this->buildAuthenticatedClient($authentication); diff --git a/src/Api/AppCatalog/AppCatalogApi.php b/src/Api/AppCatalog/AppCatalogApi.php index 2fee8662..a2d52cd8 100644 --- a/src/Api/AppCatalog/AppCatalogApi.php +++ b/src/Api/AppCatalog/AppCatalogApi.php @@ -20,8 +20,11 @@ class AppCatalogApi implements AppCatalogApiInterface public const APP_CATALOGS_URI = 'api/rest/v1/catalogs'; public const APP_CATALOG_URI = 'api/rest/v1/catalogs/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } public function listPerPage(int $limit = 100, bool $withCount = false, array $queryParameters = []): PageInterface diff --git a/src/Api/AppCatalog/AppCatalogProductApi.php b/src/Api/AppCatalog/AppCatalogProductApi.php index ef09ec67..952f0b51 100644 --- a/src/Api/AppCatalog/AppCatalogProductApi.php +++ b/src/Api/AppCatalog/AppCatalogProductApi.php @@ -17,8 +17,11 @@ class AppCatalogProductApi implements AppCatalogProductApiInterface { public const APP_CATALOG_PRODUCT_URI = '/api/rest/v1/catalogs/%s/product-uuids'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AssetApi.php b/src/Api/AssetApi.php index 8fabde31..83ebb940 100644 --- a/src/Api/AssetApi.php +++ b/src/Api/AssetApi.php @@ -25,8 +25,11 @@ class AssetApi implements AssetApiInterface public const ASSETS_URI = '/api/rest/v1/assets'; public const ASSET_URI = '/api/rest/v1/assets/%s'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AssetCategoryApi.php b/src/Api/AssetCategoryApi.php index 4180bce5..8f672d7e 100644 --- a/src/Api/AssetCategoryApi.php +++ b/src/Api/AssetCategoryApi.php @@ -25,8 +25,11 @@ class AssetCategoryApi implements AssetCategoryApiInterface public const ASSET_CATEGORIES_URI = '/api/rest/v1/asset-categories'; public const ASSET_CATEGORY_URI = '/api/rest/v1/asset-categories/%s'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AssetManager/AssetApi.php b/src/Api/AssetManager/AssetApi.php index 96b3047f..f9390958 100644 --- a/src/Api/AssetManager/AssetApi.php +++ b/src/Api/AssetManager/AssetApi.php @@ -11,11 +11,14 @@ class AssetApi implements AssetApiInterface { - public const ASSET_URI= 'api/rest/v1/asset-families/%s/assets/%s'; + public const ASSET_URI = 'api/rest/v1/asset-families/%s/assets/%s'; public const ASSETS_URI = 'api/rest/v1/asset-families/%s/assets'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AssetManager/AssetAttributeApi.php b/src/Api/AssetManager/AssetAttributeApi.php index 9a803612..d9c8eef1 100644 --- a/src/Api/AssetManager/AssetAttributeApi.php +++ b/src/Api/AssetManager/AssetAttributeApi.php @@ -11,8 +11,9 @@ class AssetAttributeApi implements AssetAttributeApiInterface public const ASSET_ATTRIBUTE_URI = 'api/rest/v1/asset-families/%s/attributes/%s'; public const ASSET_ATTRIBUTES_URI = 'api/rest/v1/asset-families/%s/attributes'; - public function __construct(private ResourceClientInterface $resourceClient) - { + public function __construct( + private ResourceClientInterface $resourceClient + ) { } /** diff --git a/src/Api/AssetManager/AssetAttributeOptionApi.php b/src/Api/AssetManager/AssetAttributeOptionApi.php index 5a17b9e3..062669a3 100644 --- a/src/Api/AssetManager/AssetAttributeOptionApi.php +++ b/src/Api/AssetManager/AssetAttributeOptionApi.php @@ -11,8 +11,9 @@ class AssetAttributeOptionApi implements AssetAttributeOptionApiInterface public const ASSET_ATTRIBUTE_OPTION_URI = 'api/rest/v1/asset-families/%s/attributes/%s/options/%s'; public const ASSET_ATTRIBUTE_OPTIONS_URI = 'api/rest/v1/asset-families/%s/attributes/%s/options'; - public function __construct(private ResourceClientInterface $resourceClient) - { + public function __construct( + private ResourceClientInterface $resourceClient + ) { } /** diff --git a/src/Api/AssetManager/AssetFamilyApi.php b/src/Api/AssetManager/AssetFamilyApi.php index a294f3dd..8a1e3c65 100644 --- a/src/Api/AssetManager/AssetFamilyApi.php +++ b/src/Api/AssetManager/AssetFamilyApi.php @@ -12,10 +12,13 @@ class AssetFamilyApi implements AssetFamilyApiInterface { public const ASSET_FAMILY_URI = 'api/rest/v1/asset-families/%s'; - public const ASSET_FAMILIES_URI= 'api/rest/v1/asset-families'; + public const ASSET_FAMILIES_URI = 'api/rest/v1/asset-families'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AssetManager/AssetMediaFileApi.php b/src/Api/AssetManager/AssetMediaFileApi.php index d5e61807..55a418b2 100644 --- a/src/Api/AssetManager/AssetMediaFileApi.php +++ b/src/Api/AssetManager/AssetMediaFileApi.php @@ -14,8 +14,10 @@ class AssetMediaFileApi implements AssetMediaFileApiInterface public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/asset-media-files/%s'; public const MEDIA_FILE_CREATE_URI = 'api/rest/v1/asset-media-files'; - public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private FileSystemInterface $fileSystem + ) { } /** diff --git a/src/Api/AssetReferenceFileApi.php b/src/Api/AssetReferenceFileApi.php index 1eb52ebc..7e920ad8 100644 --- a/src/Api/AssetReferenceFileApi.php +++ b/src/Api/AssetReferenceFileApi.php @@ -24,8 +24,10 @@ class AssetReferenceFileApi implements AssetReferenceFileApiInterface public const ASSET_REFERENCE_FILE_DOWNLOAD_URI = '/api/rest/v1/assets/%s/reference-files/%s/download'; public const NOT_LOCALIZABLE_ASSET_LOCALE_CODE = 'no-locale'; - public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private FileSystemInterface $fileSystem + ) { } /** @@ -92,7 +94,11 @@ private function upload($referenceFile, string $assetCode, string $localeCode): 'contents' => $referenceFile, ]]; - $response = $this->resourceClient->createMultipartResource(static::ASSET_REFERENCE_FILE_URI, [$assetCode, $localeCode], $requestParts); + $response = $this->resourceClient->createMultipartResource( + static::ASSET_REFERENCE_FILE_URI, + [$assetCode, $localeCode], + $requestParts + ); $this->handleUploadErrors($response); return $response->getStatusCode(); diff --git a/src/Api/AssetTagApi.php b/src/Api/AssetTagApi.php index 672b4fbc..5749f3f2 100644 --- a/src/Api/AssetTagApi.php +++ b/src/Api/AssetTagApi.php @@ -23,8 +23,11 @@ class AssetTagApi implements AssetTagApiInterface public const ASSET_TAGS_URI = '/api/rest/v1/asset-tags'; public const ASSET_TAG_URI = '/api/rest/v1/asset-tags/%s'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AssetVariationFileApi.php b/src/Api/AssetVariationFileApi.php index abfbd8a4..e8f36335 100644 --- a/src/Api/AssetVariationFileApi.php +++ b/src/Api/AssetVariationFileApi.php @@ -22,8 +22,10 @@ class AssetVariationFileApi implements AssetVariationFileApiInterface public const ASSET_VARIATION_FILE_DOWNLOAD_URI = '/api/rest/v1/assets/%s/variation-files/%s/%s/download'; public const NOT_LOCALIZABLE_ASSET_LOCALE_CODE = 'no-locale'; - public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private FileSystemInterface $fileSystem + ) { } /** diff --git a/src/Api/AssociationTypeApi.php b/src/Api/AssociationTypeApi.php index 5dfe2541..5447c24f 100644 --- a/src/Api/AssociationTypeApi.php +++ b/src/Api/AssociationTypeApi.php @@ -19,8 +19,11 @@ class AssociationTypeApi implements AssociationTypeApiInterface public const ASSOCIATION_TYPES_URI = 'api/rest/v1/association-types'; public const ASSOCIATION_TYPE_URI = 'api/rest/v1/association-types/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** * {@inheritdoc} diff --git a/src/Api/AttributeApi.php b/src/Api/AttributeApi.php index 9258fbe9..baab98f8 100644 --- a/src/Api/AttributeApi.php +++ b/src/Api/AttributeApi.php @@ -21,8 +21,11 @@ class AttributeApi implements AttributeApiInterface public const ATTRIBUTES_URI = 'api/rest/v1/attributes'; public const ATTRIBUTE_URI = 'api/rest/v1/attributes/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AttributeGroupApi.php b/src/Api/AttributeGroupApi.php index 5f8b4585..78db2949 100644 --- a/src/Api/AttributeGroupApi.php +++ b/src/Api/AttributeGroupApi.php @@ -21,8 +21,11 @@ class AttributeGroupApi implements AttributeGroupApiInterface public const ATTRIBUTE_GROUP_URI = 'api/rest/v1/attribute-groups/%s'; public const ATTRIBUTE_GROUPS_URI = 'api/rest/v1/attribute-groups'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AttributeOptionApi.php b/src/Api/AttributeOptionApi.php index cb3305a6..fd61a6c1 100644 --- a/src/Api/AttributeOptionApi.php +++ b/src/Api/AttributeOptionApi.php @@ -21,8 +21,11 @@ class AttributeOptionApi implements AttributeOptionApiInterface public const ATTRIBUTE_OPTIONS_URI = 'api/rest/v1/attributes/%s/options'; public const ATTRIBUTE_OPTION_URI = 'api/rest/v1/attributes/%s/options/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/AuthenticationApi.php b/src/Api/AuthenticationApi.php index eb9fa47e..b1ecb6bb 100644 --- a/src/Api/AuthenticationApi.php +++ b/src/Api/AuthenticationApi.php @@ -16,8 +16,10 @@ class AuthenticationApi implements AuthenticationApiInterface { public const TOKEN_URI = 'api/oauth/v1/token'; - public function __construct(protected HttpClient $httpClient, protected UriGeneratorInterface $uriGenerator) - { + public function __construct( + protected HttpClient $httpClient, + protected UriGeneratorInterface $uriGenerator + ) { } /** @@ -27,8 +29,8 @@ public function authenticateByPassword($clientId, $secret, $username, $password) { $requestBody = [ 'grant_type' => 'password', - 'username' => $username, - 'password' => $password, + 'username' => $username, + 'password' => $password, ]; return $this->authenticate($clientId, $secret, $requestBody); @@ -40,7 +42,7 @@ public function authenticateByPassword($clientId, $secret, $username, $password) public function authenticateByRefreshToken($clientId, $secret, $refreshToken): array { $requestBody = [ - 'grant_type' => 'refresh_token', + 'grant_type' => 'refresh_token', 'refresh_token' => $refreshToken ]; @@ -59,7 +61,7 @@ public function authenticateByRefreshToken($clientId, $secret, $refreshToken): a protected function authenticate($clientId, $secret, array $requestBody): array { $headers = [ - 'Content-Type' => 'application/json', + 'Content-Type' => 'application/json', 'Authorization' => sprintf('Basic %s', base64_encode($clientId . ':' . $secret)), ]; diff --git a/src/Api/CategoryApi.php b/src/Api/CategoryApi.php index 34e46ec7..95d9d524 100644 --- a/src/Api/CategoryApi.php +++ b/src/Api/CategoryApi.php @@ -21,8 +21,11 @@ class CategoryApi implements CategoryApiInterface public const CATEGORY_URI = 'api/rest/v1/categories/%s'; public const CATEGORIES_URI = 'api/rest/v1/categories'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ChannelApi.php b/src/Api/ChannelApi.php index b77e088a..de885da9 100644 --- a/src/Api/ChannelApi.php +++ b/src/Api/ChannelApi.php @@ -21,8 +21,11 @@ class ChannelApi implements ChannelApiInterface public const CHANNELS_URI = 'api/rest/v1/channels'; public const CHANNEL_URI = 'api/rest/v1/channels/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/CurrencyApi.php b/src/Api/CurrencyApi.php index 6646e843..fc6204ce 100644 --- a/src/Api/CurrencyApi.php +++ b/src/Api/CurrencyApi.php @@ -20,8 +20,11 @@ class CurrencyApi implements CurrencyApiInterface public const CURRENCY_URI = 'api/rest/v1/currencies/%s'; public const CURRENCIES_URI = 'api/rest/v1/currencies'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/FamilyApi.php b/src/Api/FamilyApi.php index 8d22856b..4a82b1a0 100644 --- a/src/Api/FamilyApi.php +++ b/src/Api/FamilyApi.php @@ -21,8 +21,11 @@ class FamilyApi implements FamilyApiInterface public const FAMILIES_URI = 'api/rest/v1/families'; public const FAMILY_URI = 'api/rest/v1/families/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/FamilyVariantApi.php b/src/Api/FamilyVariantApi.php index 0d6e4bc2..14917d23 100644 --- a/src/Api/FamilyVariantApi.php +++ b/src/Api/FamilyVariantApi.php @@ -21,8 +21,11 @@ class FamilyVariantApi implements FamilyVariantApiInterface public const FAMILY_VARIANT_URI = 'api/rest/v1/families/%s/variants/%s'; public const FAMILY_VARIANTS_URI = 'api/rest/v1/families/%s/variants'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/LocaleApi.php b/src/Api/LocaleApi.php index e3588e1a..7ef6f91c 100644 --- a/src/Api/LocaleApi.php +++ b/src/Api/LocaleApi.php @@ -20,8 +20,11 @@ class LocaleApi implements LocaleApiInterface public const LOCALES_URI = 'api/rest/v1/locales'; public const LOCALE_URI = 'api/rest/v1/locales/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/MeasureFamilyApi.php b/src/Api/MeasureFamilyApi.php index 50b518f2..c7106239 100644 --- a/src/Api/MeasureFamilyApi.php +++ b/src/Api/MeasureFamilyApi.php @@ -20,8 +20,11 @@ class MeasureFamilyApi implements MeasureFamilyApiInterface public const MEASURE_FAMILY_URI = 'api/rest/v1/measure-families/%s'; public const MEASURE_FAMILIES_URI = 'api/rest/v1/measure-families'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/MeasurementFamilyApi.php b/src/Api/MeasurementFamilyApi.php index 3a92fe15..487fd3b3 100644 --- a/src/Api/MeasurementFamilyApi.php +++ b/src/Api/MeasurementFamilyApi.php @@ -15,8 +15,9 @@ class MeasurementFamilyApi implements MeasurementFamilyApiInterface { public const MEASUREMENT_FAMILIES_URI = 'api/rest/v1/measurement-families'; - public function __construct(protected ResourceClientInterface $resourceClient) - { + public function __construct( + protected ResourceClientInterface $resourceClient + ) { } /** diff --git a/src/Api/ProductApi.php b/src/Api/ProductApi.php index 87b5e792..7ea53680 100644 --- a/src/Api/ProductApi.php +++ b/src/Api/ProductApi.php @@ -21,8 +21,11 @@ class ProductApi implements ProductApiInterface public const PRODUCTS_URI = 'api/rest/v1/products'; public const PRODUCT_URI = 'api/rest/v1/products/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ProductDraftApi.php b/src/Api/ProductDraftApi.php index ef0e1e21..9656c524 100644 --- a/src/Api/ProductDraftApi.php +++ b/src/Api/ProductDraftApi.php @@ -20,8 +20,11 @@ class ProductDraftApi implements ProductDraftApiInterface public const PRODUCT_DRAFT_URI = '/api/rest/v1/products/%s/draft'; public const PRODUCT_PROPOSAL_URI = '/api/rest/v1/products/%s/proposal'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ProductDraftUuidApi.php b/src/Api/ProductDraftUuidApi.php index 4603c417..03b59eb1 100644 --- a/src/Api/ProductDraftUuidApi.php +++ b/src/Api/ProductDraftUuidApi.php @@ -17,8 +17,11 @@ class ProductDraftUuidApi implements ProductDraftUuidApiInterface public const PRODUCT_DRAFT_UUID_URI = '/api/rest/v1/products-uuid/%s/draft'; public const PRODUCT_PROPOSAL_UUID_URI = '/api/rest/v1/products-uuid/%s/proposal'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ProductMediaFileApi.php b/src/Api/ProductMediaFileApi.php index 230d836b..06cf1fa1 100644 --- a/src/Api/ProductMediaFileApi.php +++ b/src/Api/ProductMediaFileApi.php @@ -25,8 +25,12 @@ class ProductMediaFileApi implements MediaFileApiInterface public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/media-files/%s/download'; public const MEDIA_FILE_URI_CODE_REGEX = '~/api/rest/v1/media\-files/(?P.*)$~'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory, private FileSystemInterface $fileSystem) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory, + private FileSystemInterface $fileSystem + ) { } /** diff --git a/src/Api/ProductModelApi.php b/src/Api/ProductModelApi.php index 6fc81b7c..6c3e19ec 100644 --- a/src/Api/ProductModelApi.php +++ b/src/Api/ProductModelApi.php @@ -21,8 +21,11 @@ class ProductModelApi implements ProductModelApiInterface public const PRODUCT_MODEL_URI = 'api/rest/v1/product-models/%s'; public const PRODUCT_MODELS_URI = 'api/rest/v1/product-models'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ProductModelDraftApi.php b/src/Api/ProductModelDraftApi.php index 45e30fa6..9f997f29 100644 --- a/src/Api/ProductModelDraftApi.php +++ b/src/Api/ProductModelDraftApi.php @@ -20,8 +20,11 @@ class ProductModelDraftApi implements ProductModelDraftApiInterface public const PRODUCT_MODEL_DRAFT_URI = '/api/rest/v1/product-models/%s/draft'; public const PRODUCT_MODEL_PROPOSAL_URI = '/api/rest/v1/product-models/%s/proposal'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ProductUuidApi.php b/src/Api/ProductUuidApi.php index 2bf2dd40..5a316cfe 100644 --- a/src/Api/ProductUuidApi.php +++ b/src/Api/ProductUuidApi.php @@ -20,8 +20,11 @@ class ProductUuidApi implements ProductUuidApiInterface public const PRODUCTS_UUID_URI = 'api/rest/v1/products-uuid'; public const PRODUCT_UUID_URI = 'api/rest/v1/products-uuid/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } public function listPerPage(int $limit = 100, bool $withCount = false, array $queryParameters = []): PageInterface { diff --git a/src/Api/PublishedProductApi.php b/src/Api/PublishedProductApi.php index c71c1b88..c7f66de9 100644 --- a/src/Api/PublishedProductApi.php +++ b/src/Api/PublishedProductApi.php @@ -22,8 +22,11 @@ class PublishedProductApi implements PublishedProductApiInterface public const PUBLISHED_PRODUCTS_URI = 'api/rest/v1/published-products'; public const PUBLISHED_PRODUCT_URI = 'api/rest/v1/published-products/%s'; - public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + protected ResourceClientInterface $resourceClient, + protected PageFactoryInterface $pageFactory, + protected ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ReferenceEntityApi.php b/src/Api/ReferenceEntityApi.php index 5d5fdc49..11a440ed 100644 --- a/src/Api/ReferenceEntityApi.php +++ b/src/Api/ReferenceEntityApi.php @@ -17,10 +17,13 @@ class ReferenceEntityApi implements ReferenceEntityApiInterface { public const REFERENCE_ENTITY_URI = 'api/rest/v1/reference-entities/%s'; - public const REFERENCE_ENTITIES_URI= 'api/rest/v1/reference-entities'; + public const REFERENCE_ENTITIES_URI = 'api/rest/v1/reference-entities'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Api/ReferenceEntityAttributeApi.php b/src/Api/ReferenceEntityAttributeApi.php index 6d8bb499..b5e0819b 100644 --- a/src/Api/ReferenceEntityAttributeApi.php +++ b/src/Api/ReferenceEntityAttributeApi.php @@ -16,8 +16,9 @@ class ReferenceEntityAttributeApi implements ReferenceEntityAttributeApiInterfac public const REFERENCE_ENTITY_ATTRIBUTE_URI = 'api/rest/v1/reference-entities/%s/attributes/%s'; public const REFERENCE_ENTITY_ATTRIBUTES_URI = 'api/rest/v1/reference-entities/%s/attributes'; - public function __construct(private ResourceClientInterface $resourceClient) - { + public function __construct( + private ResourceClientInterface $resourceClient + ) { } /** diff --git a/src/Api/ReferenceEntityAttributeOptionApi.php b/src/Api/ReferenceEntityAttributeOptionApi.php index 8db4b88a..29729d13 100644 --- a/src/Api/ReferenceEntityAttributeOptionApi.php +++ b/src/Api/ReferenceEntityAttributeOptionApi.php @@ -16,8 +16,9 @@ class ReferenceEntityAttributeOptionApi implements ReferenceEntityAttributeOptio public const REFERENCE_ENTITY_ATTRIBUTE_OPTION_URI = 'api/rest/v1/reference-entities/%s/attributes/%s/options/%s'; public const REFERENCE_ENTITY_ATTRIBUTE_OPTIONS_URI = 'api/rest/v1/reference-entities/%s/attributes/%s/options'; - public function __construct(private ResourceClientInterface $resourceClient) - { + public function __construct( + private ResourceClientInterface $resourceClient + ) { } /** diff --git a/src/Api/ReferenceEntityMediaFileApi.php b/src/Api/ReferenceEntityMediaFileApi.php index 2c87c175..30fa52e5 100644 --- a/src/Api/ReferenceEntityMediaFileApi.php +++ b/src/Api/ReferenceEntityMediaFileApi.php @@ -19,8 +19,10 @@ class ReferenceEntityMediaFileApi implements ReferenceEntityMediaFileApiInterfac public const MEDIA_FILE_DOWNLOAD_URI = 'api/rest/v1/reference-entities-media-files/%s'; public const MEDIA_FILE_CREATE_URI = 'api/rest/v1/reference-entities-media-files'; - public function __construct(private ResourceClientInterface $resourceClient, private FileSystemInterface $fileSystem) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private FileSystemInterface $fileSystem + ) { } /** diff --git a/src/Api/ReferenceEntityRecordApi.php b/src/Api/ReferenceEntityRecordApi.php index d46e44f9..95712961 100644 --- a/src/Api/ReferenceEntityRecordApi.php +++ b/src/Api/ReferenceEntityRecordApi.php @@ -19,8 +19,11 @@ class ReferenceEntityRecordApi implements ReferenceEntityRecordApiInterface public const REFERENCE_ENTITY_RECORD_URI = 'api/rest/v1/reference-entities/%s/records/%s'; public const REFERENCE_ENTITY_RECORDS_URI = 'api/rest/v1/reference-entities/%s/records'; - public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private PageFactoryInterface $pageFactory, + private ResourceCursorFactoryInterface $cursorFactory + ) { } /** diff --git a/src/Cache/LRUCache.php b/src/Cache/LRUCache.php index f1992174..9a4f6b91 100644 --- a/src/Cache/LRUCache.php +++ b/src/Cache/LRUCache.php @@ -11,8 +11,9 @@ class LRUCache implements CacheInterface /** * @param int $maxItems Maximum number of allowed cache items. */ - public function __construct(private int $maxItems = 100) - { + public function __construct( + private int $maxItems = 100 + ) { } /** diff --git a/src/Client/AuthenticatedHttpClient.php b/src/Client/AuthenticatedHttpClient.php index b9ce7e04..1232e648 100644 --- a/src/Client/AuthenticatedHttpClient.php +++ b/src/Client/AuthenticatedHttpClient.php @@ -22,8 +22,11 @@ */ class AuthenticatedHttpClient implements HttpClientInterface { - public function __construct(protected HttpClient $basicHttpClient, protected AuthenticationApiInterface $authenticationApi, protected Authentication $authentication) - { + public function __construct( + protected HttpClient $basicHttpClient, + protected AuthenticationApiInterface $authenticationApi, + protected Authentication $authentication + ) { } /** @@ -45,7 +48,7 @@ public function sendRequest(string $httpMethod, $uri, array $headers = [], $body } try { - $headers['Authorization'] = sprintf('Bearer %s', $this->authentication->getAccessToken()); + $headers['Authorization'] = sprintf('Bearer %s', $this->authentication->getAccessToken()); $response = $this->basicHttpClient->sendRequest($httpMethod, $uri, $headers, $body); } catch (UnauthorizedHttpException $e) { $tokens = $this->renewTokens($e); @@ -54,8 +57,8 @@ public function sendRequest(string $httpMethod, $uri, array $headers = [], $body ->setAccessToken($tokens['access_token']) ->setRefreshToken($tokens['refresh_token']); - $headers['Authorization'] = sprintf('Bearer %s', $this->authentication->getAccessToken()); - $response = $this->basicHttpClient->sendRequest($httpMethod, $uri, $headers, $body); + $headers['Authorization'] = sprintf('Bearer %s', $this->authentication->getAccessToken()); + $response = $this->basicHttpClient->sendRequest($httpMethod, $uri, $headers, $body); } return $response; diff --git a/src/Client/CachedResourceClient.php b/src/Client/CachedResourceClient.php index bd0f9016..906adab9 100644 --- a/src/Client/CachedResourceClient.php +++ b/src/Client/CachedResourceClient.php @@ -13,8 +13,10 @@ */ class CachedResourceClient implements ResourceClientInterface { - public function __construct(private ResourceClientInterface $resourceClient, private CacheInterface $cache) - { + public function __construct( + private ResourceClientInterface $resourceClient, + private CacheInterface $cache + ) { } /** @@ -22,7 +24,7 @@ public function __construct(private ResourceClientInterface $resourceClient, pri */ public function getResource(string $uri, array $uriParameters = [], array $queryParameters = []): array { - $cacheKey = md5($uri.implode('', $uriParameters)); + $cacheKey = md5($uri . implode('', $uriParameters)); if ($cachedItem = $this->cache->get($cacheKey)) { return $cachedItem; @@ -37,8 +39,13 @@ public function getResource(string $uri, array $uriParameters = [], array $query /** * {@inheritdoc} */ - public function getResources(string $uri, array $uriParameters = [], ?int $limit = 100, ?bool $withCount = false, array $queryParameters = []): array - { + public function getResources( + string $uri, + array $uriParameters = [], + ?int $limit = 100, + ?bool $withCount = false, + array $queryParameters = [] + ): array { return $this->resourceClient->getResources($uri, $uriParameters, $limit, $withCount, $queryParameters); } diff --git a/src/Client/Options.php b/src/Client/Options.php index 880d861a..ff53ca9f 100644 --- a/src/Client/Options.php +++ b/src/Client/Options.php @@ -8,8 +8,9 @@ class Options { - private function __construct(private array $options) - { + private function __construct( + private array $options + ) { } public static function fromArray(array $options): self diff --git a/src/Client/ResourceClient.php b/src/Client/ResourceClient.php index a6db5fe4..7d56f530 100644 --- a/src/Client/ResourceClient.php +++ b/src/Client/ResourceClient.php @@ -21,8 +21,12 @@ */ class ResourceClient implements ResourceClientInterface { - public function __construct(protected HttpClientInterface $httpClient, protected UriGeneratorInterface $uriGenerator, protected MultipartStreamBuilderFactory $multipartStreamBuilderFactory, protected UpsertResourceListResponseFactory $upsertListResponseFactory) - { + public function __construct( + protected HttpClientInterface $httpClient, + protected UriGeneratorInterface $uriGenerator, + protected MultipartStreamBuilderFactory $multipartStreamBuilderFactory, + protected UpsertResourceListResponseFactory $upsertListResponseFactory + ) { } /** diff --git a/src/Client/ResourceClientInterface.php b/src/Client/ResourceClientInterface.php index d43536f5..4cdd408e 100644 --- a/src/Client/ResourceClientInterface.php +++ b/src/Client/ResourceClientInterface.php @@ -48,7 +48,13 @@ public function getResource(string $uri, array $uriParameters = [], array $query * * @return array */ - public function getResources(string $uri, array $uriParameters = [], ?int $limit = 100, ?bool $withCount = false, array $queryParameters = []): array; + public function getResources( + string $uri, + array $uriParameters = [], + ?int $limit = 100, + ?bool $withCount = false, + array $queryParameters = [] + ): array; /** * Creates a resource. diff --git a/src/Exception/HttpException.php b/src/Exception/HttpException.php index e0d1d659..9e2ce382 100644 --- a/src/Exception/HttpException.php +++ b/src/Exception/HttpException.php @@ -17,8 +17,12 @@ class HttpException extends RuntimeException /** @var ResponseInterface */ protected $response; - public function __construct(string $message, protected RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null) - { + public function __construct( + string $message, + protected RequestInterface $request, + ResponseInterface $response, + ?\Exception $previous = null + ) { $message .= ' ' . $this->getAdditionalInformationMessage(); parent::__construct($message, $response->getStatusCode(), $previous); diff --git a/src/Exception/UploadAssetReferenceFileErrorException.php b/src/Exception/UploadAssetReferenceFileErrorException.php index a88f10d5..83062abd 100644 --- a/src/Exception/UploadAssetReferenceFileErrorException.php +++ b/src/Exception/UploadAssetReferenceFileErrorException.php @@ -17,8 +17,10 @@ class UploadAssetReferenceFileErrorException extends RuntimeException /** * @param string $message */ - public function __construct($message, private array $errors) - { + public function __construct( + $message, + private array $errors + ) { parent::__construct($message); } diff --git a/src/MultipartStream/MultipartStreamBuilder.php b/src/MultipartStream/MultipartStreamBuilder.php index 599344fe..7ebca464 100644 --- a/src/MultipartStream/MultipartStreamBuilder.php +++ b/src/MultipartStream/MultipartStreamBuilder.php @@ -25,8 +25,9 @@ class MultipartStreamBuilder private array $data = []; - public function __construct(private StreamFactoryInterface $streamFactory) - { + public function __construct( + private StreamFactoryInterface $streamFactory + ) { } /** @@ -84,8 +85,8 @@ public function build() $streams = ''; foreach ($this->data as $data) { // Add start and headers - $streams .= "--{$this->getBoundary()}\r\n". - $this->getHeaders($data['headers'])."\r\n"; + $streams .= "--{$this->getBoundary()}\r\n" . + $this->getHeaders($data['headers']) . "\r\n"; // Convert the stream to string /* @var $contentStream StreamInterface */ @@ -131,7 +132,9 @@ private function prepareHeaders($name, StreamInterface $stream, $filename, array } // Set a default Content-Type if one was not provided - if (!$this->hasHeader($headers, 'content-type') && $hasFilename && ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename))) { + if (!$this->hasHeader($headers, 'content-type') && $hasFilename && ($type = $this->getMimetypeHelper()->getMimetypeFromFilename( + $filename + ))) { $headers['Content-Type'] = $type; } } @@ -255,7 +258,7 @@ private function basename($path) $path = rtrim($path, $separators); // Returns the trailing part of the $path starting after one of the directory separators. - $filename = preg_match('@[^'.preg_quote($separators, '@').']+$@', $path, $matches) ? $matches[0] : ''; + $filename = preg_match('@[^' . preg_quote($separators, '@') . ']+$@', $path, $matches) ? $matches[0] : ''; return $filename; } diff --git a/src/Pagination/Page.php b/src/Pagination/Page.php index 887ba87e..15e616e0 100644 --- a/src/Pagination/Page.php +++ b/src/Pagination/Page.php @@ -13,8 +13,15 @@ */ class Page implements PageInterface { - public function __construct(protected PageFactoryInterface $pageFactory, protected HttpClientInterface $httpClient, protected string $firstLink, protected ?string$previousLink, protected ?string $nextLink, protected ?int $count, protected array $items) - { + public function __construct( + protected PageFactoryInterface $pageFactory, + protected HttpClientInterface $httpClient, + protected string $firstLink, + protected ?string$previousLink, + protected ?string $nextLink, + protected ?int $count, + protected array $items + ) { } /** diff --git a/src/Pagination/PageFactory.php b/src/Pagination/PageFactory.php index ad469ec0..0ebb2ce9 100644 --- a/src/Pagination/PageFactory.php +++ b/src/Pagination/PageFactory.php @@ -13,8 +13,9 @@ */ class PageFactory implements PageFactoryInterface { - public function __construct(protected HttpClientInterface $httpClient) - { + public function __construct( + protected HttpClientInterface $httpClient + ) { } /** diff --git a/src/Pagination/ResourceCursor.php b/src/Pagination/ResourceCursor.php index 4f269a0e..470ee924 100644 --- a/src/Pagination/ResourceCursor.php +++ b/src/Pagination/ResourceCursor.php @@ -15,8 +15,10 @@ class ResourceCursor implements ResourceCursorInterface protected int $currentIndex = 0; protected int $totalIndex = 0; - public function __construct(protected ?int $pageSize, protected PageInterface $firstPage) - { + public function __construct( + protected ?int $pageSize, + protected PageInterface $firstPage + ) { $this->currentPage = $firstPage; } diff --git a/src/Search/SearchBuilder.php b/src/Search/SearchBuilder.php index 05d3f161..c48ba97a 100644 --- a/src/Search/SearchBuilder.php +++ b/src/Search/SearchBuilder.php @@ -27,7 +27,7 @@ class SearchBuilder */ public function addFilter(string $property, string $operator, $value = null, array $options = []): self { - $filter = ['operator'=> $operator]; + $filter = ['operator' => $operator]; if (null !== $value) { $filter['value'] = $value; diff --git a/src/Stream/LineStreamReader.php b/src/Stream/LineStreamReader.php index 87856c27..d934235d 100644 --- a/src/Stream/LineStreamReader.php +++ b/src/Stream/LineStreamReader.php @@ -24,7 +24,7 @@ public function getNextLine(StreamInterface $stream): ?string return null; } - $line = ''; + $line = ''; $isEol = false; while (!$stream->eof() && !$isEol) { $character = $stream->read(1); diff --git a/src/Stream/MultipartStreamBuilderFactory.php b/src/Stream/MultipartStreamBuilderFactory.php index 021bc885..5ef68ca6 100644 --- a/src/Stream/MultipartStreamBuilderFactory.php +++ b/src/Stream/MultipartStreamBuilderFactory.php @@ -14,8 +14,9 @@ */ class MultipartStreamBuilderFactory { - public function __construct(protected StreamFactoryInterface $streamFactory) - { + public function __construct( + protected StreamFactoryInterface $streamFactory + ) { } public function create(): MultipartStreamBuilder diff --git a/src/Stream/UpsertResourceListResponse.php b/src/Stream/UpsertResourceListResponse.php index 6704739a..cfba42c7 100644 --- a/src/Stream/UpsertResourceListResponse.php +++ b/src/Stream/UpsertResourceListResponse.php @@ -24,8 +24,10 @@ class UpsertResourceListResponse implements \Iterator /** @var string */ protected $line; - public function __construct(protected StreamInterface $bodyStream, protected LineStreamReader $streamReader) - { + public function __construct( + protected StreamInterface $bodyStream, + protected LineStreamReader $streamReader + ) { } /** diff --git a/tests/Api/ApiTestCase.php b/tests/Api/ApiTestCase.php index 9ae97631..61867e02 100644 --- a/tests/Api/ApiTestCase.php +++ b/tests/Api/ApiTestCase.php @@ -28,7 +28,7 @@ protected function setUp(): void $this->server->start(); $this->server->setResponseOfPath( - '/'. AuthenticationApi::TOKEN_URI, + '/' . AuthenticationApi::TOKEN_URI, new ResponseStack( new Response($this->getAuthenticatedJson()) ) diff --git a/tests/Api/AppCatalog/CreateAppCatalogIntegration.php b/tests/Api/AppCatalog/CreateAppCatalogIntegration.php index d4d55b33..6a84e9cd 100644 --- a/tests/Api/AppCatalog/CreateAppCatalogIntegration.php +++ b/tests/Api/AppCatalog/CreateAppCatalogIntegration.php @@ -1,4 +1,5 @@ server->setResponseOfPath( - '/'.AppCatalogApi::APP_CATALOGS_URI, + '/' . AppCatalogApi::APP_CATALOGS_URI, new ResponseStack( new Response($expectedJson, [], HttpClient::HTTP_CREATED) ) diff --git a/tests/Api/AppCatalog/DeleteAppCatalogIntegration.php b/tests/Api/AppCatalog/DeleteAppCatalogIntegration.php index 75c4f214..72f7fd48 100644 --- a/tests/Api/AppCatalog/DeleteAppCatalogIntegration.php +++ b/tests/Api/AppCatalog/DeleteAppCatalogIntegration.php @@ -1,4 +1,5 @@ server->setResponseOfPath( - '/'.sprintf(AppCatalogApi::APP_CATALOG_URI, $catalogId), + '/' . sprintf(AppCatalogApi::APP_CATALOG_URI, $catalogId), new ResponseStack( new Response('', [], HttpClient::HTTP_NO_CONTENT) ) diff --git a/tests/Api/AppCatalog/GetAppCatalogIntegration.php b/tests/Api/AppCatalog/GetAppCatalogIntegration.php index 0cd474d2..9e4921c6 100644 --- a/tests/Api/AppCatalog/GetAppCatalogIntegration.php +++ b/tests/Api/AppCatalog/GetAppCatalogIntegration.php @@ -1,4 +1,5 @@ server->setResponseOfPath( - '/'.sprintf(AppCatalogApi::APP_CATALOG_URI, $catalogId), + '/' . sprintf(AppCatalogApi::APP_CATALOG_URI, $catalogId), new ResponseStack( new Response($this->getACatalog(), [], HttpClient::HTTP_OK) ) diff --git a/tests/Api/AppCatalog/ListAppCatalogIntegration.php b/tests/Api/AppCatalog/ListAppCatalogIntegration.php index 9b05858d..03eec19c 100644 --- a/tests/Api/AppCatalog/ListAppCatalogIntegration.php +++ b/tests/Api/AppCatalog/ListAppCatalogIntegration.php @@ -1,4 +1,5 @@ server->setResponseOfPath( - '/'.sprintf(AppCatalogApi::APP_CATALOG_URI, $catalogId), + '/' . sprintf(AppCatalogApi::APP_CATALOG_URI, $catalogId), new ResponseStack( new Response($expectedJson, [], HttpClient::HTTP_OK) ) diff --git a/tests/Api/AppCatalogProduct/ListAppCatalogProductIntegration.php b/tests/Api/AppCatalogProduct/ListAppCatalogProductIntegration.php index 6891c0e5..51f7199e 100644 --- a/tests/Api/AppCatalogProduct/ListAppCatalogProductIntegration.php +++ b/tests/Api/AppCatalogProduct/ListAppCatalogProductIntegration.php @@ -1,4 +1,5 @@ server->setResponseOfPath( - '/'. sprintf(AssetApi::ASSET_URI, 'packshot', 'battleship'), + '/' . sprintf(AssetApi::ASSET_URI, 'packshot', 'battleship'), new ResponseStack( new Response($this->getAsset(), [], 200) ) @@ -32,7 +32,7 @@ public function test_get_asset() public function test_get_unknown_asset() { $this->server->setResponseOfPath( - '/'. sprintf(AssetApi::ASSET_URI, 'packshot', 'peace-sheep'), + '/' . sprintf(AssetApi::ASSET_URI, 'packshot', 'peace-sheep'), new ResponseStack( new Response('{"code": 404, "message":"Asset \"peace-sheep\" does not exist."}', [], 404) ) diff --git a/tests/Api/Asset/ListAllAssetsIntegration.php b/tests/Api/Asset/ListAllAssetsIntegration.php index e8a085eb..8ac16101 100644 --- a/tests/Api/Asset/ListAllAssetsIntegration.php +++ b/tests/Api/Asset/ListAllAssetsIntegration.php @@ -15,7 +15,7 @@ class ListAllAssetsIntegration extends ApiTestCase public function test_list_per_page() { $this->server->setResponseOfPath( - '/'. sprintf(AssetApi::ASSETS_URI, 'packshot'), + '/' . sprintf(AssetApi::ASSETS_URI, 'packshot'), new ResponseStack( new Response($this->getFirstPage(), [], 200), new Response($this->getSecondPage(), [], 200) diff --git a/tests/Api/Asset/UpsertAssetIntegration.php b/tests/Api/Asset/UpsertAssetIntegration.php index a2ddc3b8..d39a80fa 100644 --- a/tests/Api/Asset/UpsertAssetIntegration.php +++ b/tests/Api/Asset/UpsertAssetIntegration.php @@ -16,7 +16,7 @@ class UpsertAssetIntegration extends ApiTestCase public function test_upsert_asset() { $this->server->setResponseOfPath( - '/'. sprintf(AssetApi::ASSET_URI, 'packshot', 'sku_54628_telescope'), + '/' . sprintf(AssetApi::ASSET_URI, 'packshot', 'sku_54628_telescope'), new ResponseStack( new Response('', [], 204) ) diff --git a/tests/Api/Asset/UpsertListAssetIntegration.php b/tests/Api/Asset/UpsertListAssetIntegration.php index fb3d0734..9ff1737a 100644 --- a/tests/Api/Asset/UpsertListAssetIntegration.php +++ b/tests/Api/Asset/UpsertListAssetIntegration.php @@ -29,7 +29,7 @@ public function test_upsert_a_list_of_assets() JSON; $this->server->setResponseOfPath( - '/'. sprintf(AssetApi::ASSETS_URI, 'packshot'), + '/' . sprintf(AssetApi::ASSETS_URI, 'packshot'), new ResponseStack( new Response($responseBody, [], 200) ) diff --git a/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php b/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php index e286b4de..4fe45ca3 100644 --- a/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php +++ b/tests/Api/AssetAttribute/GetAssetFamilyAttributeIntegration.php @@ -17,7 +17,7 @@ class GetAssetFamilyAttributeIntegration extends ApiTestCase public function test_get_asset_family_attribute() { $this->server->setResponseOfPath( - '/'. sprintf(AssetAttributeApi::ASSET_ATTRIBUTE_URI, 'packshot', 'media_preview'), + '/' . sprintf(AssetAttributeApi::ASSET_ATTRIBUTE_URI, 'packshot', 'media_preview'), new ResponseStack( new Response($this->getPackshotPreviewAttribute(), [], 200) ) @@ -33,7 +33,7 @@ public function test_get_asset_family_attribute() public function test_get_unknown_asset_family_attribute() { $this->server->setResponseOfPath( - '/'. sprintf(AssetAttributeApi::ASSET_ATTRIBUTE_URI, 'packshot', 'foo'), + '/' . sprintf(AssetAttributeApi::ASSET_ATTRIBUTE_URI, 'packshot', 'foo'), new ResponseStack( new Response('{"code": 404, "message":"Resource `foo` does not exist."}', [], 404) ) diff --git a/tests/Api/AssetAttribute/UpsertAssetFamilyAttributeIntegration.php b/tests/Api/AssetAttribute/UpsertAssetFamilyAttributeIntegration.php index b8981f7b..b4b05b03 100644 --- a/tests/Api/AssetAttribute/UpsertAssetFamilyAttributeIntegration.php +++ b/tests/Api/AssetAttribute/UpsertAssetFamilyAttributeIntegration.php @@ -16,7 +16,7 @@ class UpsertAssetFamilyAttributeIntegration extends ApiTestCase public function test_upsert_asset_family_attribute() { $this->server->setResponseOfPath( - '/'. sprintf(AssetAttributeApi::ASSET_ATTRIBUTE_URI, 'packshot', 'media_preview'), + '/' . sprintf(AssetAttributeApi::ASSET_ATTRIBUTE_URI, 'packshot', 'media_preview'), new ResponseStack( new Response('', [], 204) ) @@ -39,7 +39,10 @@ public function test_upsert_asset_family_attribute() $api = $this->createClientByPassword()->getAssetAttributeApi(); $response = $api->upsert('packshot', 'media_preview', $assetFamilyAttribute); - Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT], json_encode($assetFamilyAttribute)); + Assert::assertSame( + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT], + json_encode($assetFamilyAttribute) + ); Assert::assertSame(204, $response); } } diff --git a/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php b/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php index 54bc64db..5a70c333 100644 --- a/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php +++ b/tests/Api/AssetAttributeOption/GetAssetFamilyAttributeOptionIntegration.php @@ -17,7 +17,7 @@ class GetAssetFamilyAttributeOptionIntegration extends ApiTestCase public function test_get_asset_family_attribute_option() { $this->server->setResponseOfPath( - '/'. sprintf(AssetAttributeOptionApi::ASSET_ATTRIBUTE_OPTION_URI, 'packshot', 'wearing_model_size', 'small'), + '/' . sprintf(AssetAttributeOptionApi::ASSET_ATTRIBUTE_OPTION_URI, 'packshot', 'wearing_model_size', 'small'), new ResponseStack( new Response($this->getPackshotAttributeOption(), [], 200) ) @@ -33,7 +33,7 @@ public function test_get_asset_family_attribute_option() public function test_get_unknown_asset_family_attribute_option() { $this->server->setResponseOfPath( - '/'. sprintf(AssetAttributeOptionApi::ASSET_ATTRIBUTE_OPTION_URI, 'packshot', 'wearing_model_size', 'XLS'), + '/' . sprintf(AssetAttributeOptionApi::ASSET_ATTRIBUTE_OPTION_URI, 'packshot', 'wearing_model_size', 'XLS'), new ResponseStack( new Response('{"code": 404, "message":"Resource `XLS` does not exist."}', [], 404) ) diff --git a/tests/Api/AssetAttributeOption/UpsertAssetFamilyAttributeOptionIntegration.php b/tests/Api/AssetAttributeOption/UpsertAssetFamilyAttributeOptionIntegration.php index f65e790e..d6364af5 100644 --- a/tests/Api/AssetAttributeOption/UpsertAssetFamilyAttributeOptionIntegration.php +++ b/tests/Api/AssetAttributeOption/UpsertAssetFamilyAttributeOptionIntegration.php @@ -16,7 +16,7 @@ class UpsertAssetFamilyAttributeOptionIntegration extends ApiTestCase public function test_upsert_asset_family_attribute_option() { $this->server->setResponseOfPath( - '/'. sprintf( + '/' . sprintf( AssetAttributeOptionApi::ASSET_ATTRIBUTE_OPTION_URI, 'packshot', 'wearing_model_size', @@ -38,7 +38,10 @@ public function test_upsert_asset_family_attribute_option() $api = $this->createClientByPassword()->getAssetAttributeOptionApi(); $response = $api->upsert('packshot', 'wearing_model_size', 'size_27', $assetFamilyAttributeOption); - Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT], json_encode($assetFamilyAttributeOption)); + Assert::assertSame( + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT], + json_encode($assetFamilyAttributeOption) + ); Assert::assertSame(204, $response); } } diff --git a/tests/Api/AssetFamily/GetAssetFamilyIntegration.php b/tests/Api/AssetFamily/GetAssetFamilyIntegration.php index eb4ed095..4e43a281 100644 --- a/tests/Api/AssetFamily/GetAssetFamilyIntegration.php +++ b/tests/Api/AssetFamily/GetAssetFamilyIntegration.php @@ -17,7 +17,7 @@ class GetAssetFamilyIntegration extends ApiTestCase public function test_get_asset_family() { $this->server->setResponseOfPath( - '/'. sprintf(AssetFamilyApi::ASSET_FAMILY_URI, 'packshot'), + '/' . sprintf(AssetFamilyApi::ASSET_FAMILY_URI, 'packshot'), new ResponseStack( new Response($this->getPackshot(), [], 200) ) @@ -33,7 +33,7 @@ public function test_get_asset_family() public function test_get_unknown_asset_family() { $this->server->setResponseOfPath( - '/'. sprintf(AssetFamilyApi::ASSET_FAMILY_URI, 'foo'), + '/' . sprintf(AssetFamilyApi::ASSET_FAMILY_URI, 'foo'), new ResponseStack( new Response('{"code": 404, "message":"Asset family \"foo\" does not exist."}', [], 404) ) diff --git a/tests/Api/AssetFamily/UpsertAssetFamilyIntegration.php b/tests/Api/AssetFamily/UpsertAssetFamilyIntegration.php index 8a3d3110..71043513 100644 --- a/tests/Api/AssetFamily/UpsertAssetFamilyIntegration.php +++ b/tests/Api/AssetFamily/UpsertAssetFamilyIntegration.php @@ -14,7 +14,7 @@ class UpsertAssetFamilyIntegration extends ApiTestCase public function test_upsert_asset_family() { $this->server->setResponseOfPath( - '/'. sprintf(AssetFamilyApi::ASSET_FAMILY_URI, 'packshot'), + '/' . sprintf(AssetFamilyApi::ASSET_FAMILY_URI, 'packshot'), new ResponseStack( new Response('', [], 201) ) diff --git a/tests/Api/AssetReferenceFile/DownloadAssetReferenceFileIntegration.php b/tests/Api/AssetReferenceFile/DownloadAssetReferenceFileIntegration.php index 125af370..5e01783e 100644 --- a/tests/Api/AssetReferenceFile/DownloadAssetReferenceFileIntegration.php +++ b/tests/Api/AssetReferenceFile/DownloadAssetReferenceFileIntegration.php @@ -17,7 +17,7 @@ public function test_download_a_localizable_asset_reference_file() $expectedFilePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, 'ziggy', 'en_US'), + '/' . sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, 'ziggy', 'en_US'), new ResponseStack( new Response(file_get_contents($expectedFilePath), [], 201) ) @@ -37,7 +37,11 @@ public function test_download_a_not_localizable_asset_reference_file() $expectedFilePath = realpath(__DIR__ . '/../../fixtures/ziggy-certification.jpg'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, 'ziggy_certif', AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, + 'ziggy_certif', + AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response(file_get_contents($expectedFilePath), [], 201) ) @@ -58,7 +62,7 @@ public function test_download_a_not_localizable_asset_reference_file() public function test_download_from_localizable_asset_not_found() { $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, 'ziggy', 'en_US'), + '/' . sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, 'ziggy', 'en_US'), new ResponseStack( new Response('{"code": 404, "message":"Not found"}', [], 404) ) @@ -74,7 +78,11 @@ public function test_download_from_localizable_asset_not_found() public function test_download_from_not_localizable_asset_not_found() { $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, 'ziggy_certif', AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetReferenceFileApi::ASSET_REFERENCE_FILE_DOWNLOAD_URI, + 'ziggy_certif', + AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response('{"code": 404, "message":"Not found"}', [], 404) ) diff --git a/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php b/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php index ddef901d..a07b2c50 100644 --- a/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php +++ b/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php @@ -16,7 +16,7 @@ public function test_upload_a_localizable_asset_reference_file() $filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'ziggy', 'en_US'), + '/' . sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'ziggy', 'en_US'), new ResponseStack( new Response(file_get_contents($filePath), [], 201), new Response(json_encode($this->fakeUploadLocalizableInformations()), [], 201) @@ -45,7 +45,11 @@ public function test_upload_a_not_localizable_asset_reference_file() $filePath = realpath(__DIR__ . '/../../fixtures/ziggy-certification.jpg'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'ziggy-certification', AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, + 'ziggy-certification', + AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response(file_get_contents($filePath), [], 201), new Response(json_encode($this->fakeUploadNotLocalizableInformations()), [], 201) @@ -57,7 +61,10 @@ public function test_upload_a_not_localizable_asset_reference_file() Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_METHOD], 'POST'); Assert::assertNotEmpty($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']); - Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['name'], 'ziggy-certification.jpg'); + Assert::assertSame( + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['name'], + 'ziggy-certification.jpg' + ); Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['type'], 'image/jpeg'); Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['size'], 10513); @@ -75,7 +82,7 @@ public function test_upload_from_resource_file() $file = fopen($filePath, 'rb'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'ziggy', 'en_US'), + '/' . sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'ziggy', 'en_US'), new ResponseStack( new Response(file_get_contents($filePath), [], 201), new Response(json_encode($this->fakeUploadLocalizableInformations()), [], 201) @@ -107,7 +114,7 @@ public function test_upload_for_an_unknown_asset() $filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unknown_asset', 'en_US'), + '/' . sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unknown_asset', 'en_US'), new ResponseStack( new Response('{"code": 404, "message":"Not found"}', [], 404) ) @@ -126,7 +133,11 @@ public function test_upload_a_file_that_cannot_be_transformed_for_the_variations $filePath = realpath(__DIR__ . '/../../fixtures/unicorn.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unicorn', AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, + 'unicorn', + AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response(json_encode($this->generateMessageForUploadAssetReferenceFileErrorException())) ) @@ -137,23 +148,25 @@ public function test_upload_a_file_that_cannot_be_transformed_for_the_variations $api->uploadForNotLocalizableAsset($filePath, 'unicorn'); } - protected function fakeUploadLocalizableInformations(){ + protected function fakeUploadLocalizableInformations() + { return [ - 'code' => '5/c/8/3/5c835e7785cb174d8e7e39d7ee63be559f233be0_ziggy.jpg', + 'code' => '5/c/8/3/5c835e7785cb174d8e7e39d7ee63be559f233be0_ziggy.jpg', 'locale' => 'en_US', - '_link' => [ + '_link' => [ 'download' => [ - 'href' => '/api/rest/v1/assets/ziggy/reference-files/en_US/download' + 'href' => '/api/rest/v1/assets/ziggy/reference-files/en_US/download' ] ], ]; } - protected function fakeUploadNotLocalizableInformations(){ + protected function fakeUploadNotLocalizableInformations() + { return [ - 'code' => '5/c/8/3/5c835e7785cb174d8e7e39d7ee63be559f233be0_ziggy_certification.jpg', + 'code' => '5/c/8/3/5c835e7785cb174d8e7e39d7ee63be559f233be0_ziggy_certification.jpg', 'locale' => null, - '_link' => [ + '_link' => [ 'download' => [ 'href' => '/api/rest/v1/assets/ziggy_certif/reference-files/no-locale/download' ] @@ -161,7 +174,8 @@ protected function fakeUploadNotLocalizableInformations(){ ]; } - protected function generateMessageForUploadAssetReferenceFileErrorException(){ + protected function generateMessageForUploadAssetReferenceFileErrorException() + { return [ 'message' => 'Some variation files were not generated properly.', 'errors' => [ diff --git a/tests/Api/AssetVariationFile/DownloadAssetVariationFileApiIntegration.php b/tests/Api/AssetVariationFile/DownloadAssetVariationFileApiIntegration.php index 9e3eb3a4..26561a96 100644 --- a/tests/Api/AssetVariationFile/DownloadAssetVariationFileApiIntegration.php +++ b/tests/Api/AssetVariationFile/DownloadAssetVariationFileApiIntegration.php @@ -12,13 +12,12 @@ class DownloadAssetVariationFileApiIntegration extends ApiTestCase { - public function test_download_a_localizable_asset_variation_file() { $expectedFilePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, 'ziggy', 'ecommerce', 'en_US'), + '/' . sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, 'ziggy', 'ecommerce', 'en_US'), new ResponseStack( new Response(file_get_contents($expectedFilePath), [], 201) ) @@ -39,7 +38,12 @@ public function test_download_a_not_localizable_asset_variation_file() $expectedFilePath = realpath(__DIR__ . '/../../fixtures/ziggy-certification.jpg'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, 'ziggy_certif', 'ecommerce', AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, + 'ziggy_certif', + 'ecommerce', + AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response(file_get_contents($expectedFilePath), [], 201) ) @@ -60,7 +64,7 @@ public function test_download_a_not_localizable_asset_variation_file() public function test_download_from_localizable_asset_not_found() { $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, 'ziggy', 'mobile', 'en_US'), + '/' . sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, 'ziggy', 'mobile', 'en_US'), new ResponseStack( new Response('{"code": 404, "message":"Not found"}', [], 404) ) @@ -76,7 +80,12 @@ public function test_download_from_localizable_asset_not_found() public function test_download_from_not_localizable_asset_not_found() { $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, 'ziggy_certif', 'mobile', AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetVariationFileApi::ASSET_VARIATION_FILE_DOWNLOAD_URI, + 'ziggy_certif', + 'mobile', + AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response('{"code": 404, "message":"Not found"}', [], 404) ) diff --git a/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php b/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php index 20da16fa..58a0502a 100644 --- a/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php +++ b/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php @@ -16,7 +16,7 @@ public function test_upload_a_localizable_asset_variation_file() $filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'ziggy', 'ecommerce', 'en_US'), + '/' . sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'ziggy', 'ecommerce', 'en_US'), new ResponseStack( new Response(file_get_contents($filePath), [], 201), new Response(json_encode($this->fakeUploadLocalizableInformations()), [], 201) @@ -46,7 +46,12 @@ public function test_upload_a_not_localizable_asset_variation_file() $filePath = realpath(__DIR__ . '/../../fixtures/ziggy-certification.jpg'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'ziggy_certif', 'ecommerce', AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetVariationFileApi::ASSET_VARIATION_FILE_URI, + 'ziggy_certif', + 'ecommerce', + AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response(file_get_contents($filePath), [], 201), new Response(json_encode($this->fakeUploadNotLocalizableInformations()), [], 201) @@ -58,7 +63,10 @@ public function test_upload_a_not_localizable_asset_variation_file() Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_METHOD], 'POST'); Assert::assertNotEmpty($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']); - Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['name'], 'ziggy-certification.jpg'); + Assert::assertSame( + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['name'], + 'ziggy-certification.jpg' + ); Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['type'], 'image/jpeg'); Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_FILES]['file']['size'], 10513); @@ -76,7 +84,7 @@ public function test_upload_from_resource_file() $file = fopen($filePath, 'rb'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'ziggy', 'ecommerce', 'en_US'), + '/' . sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'ziggy', 'ecommerce', 'en_US'), new ResponseStack( new Response(file_get_contents($filePath), [], 201), new Response(json_encode($this->fakeUploadLocalizableInformations()), [], 201) @@ -108,7 +116,7 @@ public function test_upload_for_an_unknown_asset() $filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unknown_asset', 'ecommerce', 'en_US'), + '/' . sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unknown_asset', 'ecommerce', 'en_US'), new ResponseStack( new Response('{"code": 404, "message":"Not found"}', [], 404) ) @@ -127,7 +135,12 @@ public function test_upload_for_an_asset_that_should_be_localizable() $filePath = realpath(__DIR__ . '/../../fixtures/unicorn.png'); $this->server->setResponseOfPath( - '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unicorn', 'ecommerce', AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), + '/' . sprintf( + AssetVariationFileApi::ASSET_VARIATION_FILE_URI, + 'unicorn', + 'ecommerce', + AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE + ), new ResponseStack( new Response('{"code": 422, "message":"Unprocessable Entity"}', [], 422) ) @@ -138,11 +151,12 @@ public function test_upload_for_an_asset_that_should_be_localizable() $api->uploadForNotLocalizableAsset($filePath, 'unicorn', 'ecommerce'); } - protected function fakeUploadLocalizableInformations(){ + protected function fakeUploadLocalizableInformations() + { return [ - 'code' => '5/c/8/3/5c835e7785cb174d8e7e39d7ee63be559f233be0_ziggy_ecommerce.jpg', + 'code' => '5/c/8/3/5c835e7785cb174d8e7e39d7ee63be559f233be0_ziggy_ecommerce.jpg', 'locale' => 'en_US', - '_link' => [ + '_link' => [ 'download' => [ 'href' => '/api/rest/v1/assets/ziggy/variation-files/ecommerce/en_US/download' ] @@ -150,11 +164,12 @@ protected function fakeUploadLocalizableInformations(){ ]; } - protected function fakeUploadNotLocalizableInformations(){ + protected function fakeUploadNotLocalizableInformations() + { return [ - 'code' => '2/9/b/f/29bfa18ced500c5fca2072dab978737576ca47ca_ziggy_certification_ecommerce.jpg', + 'code' => '2/9/b/f/29bfa18ced500c5fca2072dab978737576ca47ca_ziggy_certification_ecommerce.jpg', 'locale' => null, - '_link' => [ + '_link' => [ 'download' => [ 'href' => '/api/rest/v1/assets/ziggy_certif/variation-files/ecommerce/no-locale/download' ] diff --git a/tests/Api/CreateProductMediaFileTest.php b/tests/Api/CreateProductMediaFileTest.php index ce91a44a..5b843455 100644 --- a/tests/Api/CreateProductMediaFileTest.php +++ b/tests/Api/CreateProductMediaFileTest.php @@ -12,9 +12,9 @@ class CreateProductMediaFileTest extends ApiTestCase { public function test_create_media_file() { - $mediaFileURI = $this->server->getServerRoot(). '/' . ProductMediaFileApi::MEDIA_FILES_URI.'/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png'; + $mediaFileURI = $this->server->getServerRoot() . '/' . ProductMediaFileApi::MEDIA_FILES_URI . '/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png'; $this->server->setResponseOfPath( - '/'. ProductMediaFileApi::MEDIA_FILES_URI, + '/' . ProductMediaFileApi::MEDIA_FILES_URI, new ResponseStack( new Response('', ['Location' => $mediaFileURI], 201) ) @@ -25,9 +25,9 @@ public function test_create_media_file() $productInfos = [ 'identifier' => 'medium_boot', - 'attribute' => 'side_view', - 'scope' => null, - 'locale' => null, + 'attribute' => 'side_view', + 'scope' => null, + 'locale' => null, ]; $response = $api->create($mediaFile, $productInfos); @@ -45,7 +45,7 @@ public function test_create_media_file() public function test_get_created_media_file_location_regardless_of_the_header_case() { $mediaFileURI = $this->server->getServerRoot( - ) . '/' . ProductMediaFileApi::MEDIA_FILES_URI . '/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png'; + ) . '/' . ProductMediaFileApi::MEDIA_FILES_URI . '/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png'; $this->server->setResponseOfPath( '/' . ProductMediaFileApi::MEDIA_FILES_URI, new ResponseStack( diff --git a/tests/Api/CreateProductTest.php b/tests/Api/CreateProductTest.php index c560d090..e761b043 100644 --- a/tests/Api/CreateProductTest.php +++ b/tests/Api/CreateProductTest.php @@ -13,7 +13,7 @@ class CreateProductTest extends ApiTestCase public function test_create_product() { $this->server->setResponseOfPath( - '/'. ProductApi::PRODUCTS_URI, + '/' . ProductApi::PRODUCTS_URI, new ResponseStack( new Response('', [], 201) ) @@ -22,7 +22,10 @@ public function test_create_product() $api = $this->createClientByPassword()->getProductApi(); $response = $api->create('new_shoes', $this->newProduct()); - Assert::assertSame(json_encode($this->expectedProduct()), $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT]); + Assert::assertSame( + json_encode($this->expectedProduct()), + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_INPUT] + ); Assert::assertSame(201, $response); } @@ -30,11 +33,15 @@ public function test_create_product() public function test_create_invalid_product() { $this->server->setResponseOfPath( - '/'. ProductApi::PRODUCTS_URI, + '/' . ProductApi::PRODUCTS_URI, new ResponseStack( - new Response('{"code": 422, "message":"The value black_sneakers is already set on another product for the unique attribute sku"}', [], 422) + new Response( + '{"code": 422, "message":"The value black_sneakers is already set on another product for the unique attribute sku"}', + [], + 422 ) - ); + ) + ); $this->expectException(\Akeneo\Pim\ApiClient\Exception\UnprocessableEntityHttpException::class); $this->expectExceptionMessage('The value black_sneakers is already set on another product for the unique attribute sku'); @@ -46,20 +53,20 @@ public function test_create_invalid_product() private function newProduct(): array { return [ - 'enabled' => false, - 'family' => 'sandals', + 'enabled' => false, + 'family' => 'sandals', 'categories' => ['summer_collection'], - 'values' => [ + 'values' => [ 'name' => [ [ - 'data' => 'The pumps', + 'data' => 'The pumps', 'locale' => 'en_US', - 'scope' => null, + 'scope' => null, ], [ - 'data' => 'Les pumps', + 'data' => 'Les pumps', 'locale' => 'fr_FR', - 'scope' => null, + 'scope' => null, ] ] ] @@ -69,20 +76,20 @@ private function newProduct(): array private function expectedProduct(): array { return [ - 'enabled' => false, - 'family' => 'sandals', + 'enabled' => false, + 'family' => 'sandals', 'categories' => ['summer_collection'], - 'values' => [ + 'values' => [ 'name' => [ [ - 'data' => 'The pumps', + 'data' => 'The pumps', 'locale' => 'en_US', - 'scope' => null, + 'scope' => null, ], [ - 'data' => 'Les pumps', + 'data' => 'Les pumps', 'locale' => 'fr_FR', - 'scope' => null, + 'scope' => null, ] ] ], diff --git a/tests/Api/DeleteProductModelTest.php b/tests/Api/DeleteProductModelTest.php index fa152f91..19f69fa2 100644 --- a/tests/Api/DeleteProductModelTest.php +++ b/tests/Api/DeleteProductModelTest.php @@ -13,7 +13,7 @@ class DeleteProductModelTest extends ApiTestCase public function test_delete_product_model() { $this->server->setResponseOfPath( - '/'. sprintf(ProductModelApi::PRODUCT_MODEL_URI, 'docks_white'), + '/' . sprintf(ProductModelApi::PRODUCT_MODEL_URI, 'docks_white'), new ResponseStack( new Response('', [], 204) ) diff --git a/tests/Api/DeleteProductTest.php b/tests/Api/DeleteProductTest.php index 9fd5d4ab..324a3f9c 100644 --- a/tests/Api/DeleteProductTest.php +++ b/tests/Api/DeleteProductTest.php @@ -13,7 +13,7 @@ class DeleteProductTest extends ApiTestCase public function test_create_product() { $this->server->setResponseOfPath( - '/'. sprintf(ProductApi::PRODUCT_URI, 'docks_white'), + '/' . sprintf(ProductApi::PRODUCT_URI, 'docks_white'), new ResponseStack( new Response('', [], 204) ) diff --git a/tests/Api/DownloadProductMediaFileTest.php b/tests/Api/DownloadProductMediaFileTest.php index 1b8b02e0..338fbfc2 100644 --- a/tests/Api/DownloadProductMediaFileTest.php +++ b/tests/Api/DownloadProductMediaFileTest.php @@ -16,7 +16,7 @@ public function test_download_media_file() $expectedMediaFilePath = realpath(__DIR__ . '/../fixtures/akeneo.png'); $this->server->setResponseOfPath( - '/'. sprintf(ProductMediaFileApi::MEDIA_FILE_DOWNLOAD_URI, '/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png'), + '/' . sprintf(ProductMediaFileApi::MEDIA_FILE_DOWNLOAD_URI, '/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png'), new ResponseStack( new Response(file_get_contents($expectedMediaFilePath), [], 201) ) diff --git a/tests/Api/GetProductTest.php b/tests/Api/GetProductTest.php index 44f11fd7..f804918a 100644 --- a/tests/Api/GetProductTest.php +++ b/tests/Api/GetProductTest.php @@ -13,7 +13,7 @@ class GetProductTest extends ApiTestCase public function test_get_product() { $this->server->setResponseOfPath( - '/'. sprintf(ProductApi::PRODUCT_URI, 'black_sneakers'), + '/' . sprintf(ProductApi::PRODUCT_URI, 'black_sneakers'), new ResponseStack( new Response($this->getProduct(), [], 200) ) @@ -30,7 +30,7 @@ public function test_get_product() public function test_get_unknow_product() { $this->server->setResponseOfPath( - '/'. sprintf(ProductApi::PRODUCT_URI, 'black_sneakers'), + '/' . sprintf(ProductApi::PRODUCT_URI, 'black_sneakers'), new ResponseStack( new Response('{"code": 404, "message":"Resource `black_sneakers` does not exist."}', [], 404) ) diff --git a/tests/Api/ListPerPageProductTest.php b/tests/Api/ListPerPageProductTest.php index 10d44a7c..2ad84545 100644 --- a/tests/Api/ListPerPageProductTest.php +++ b/tests/Api/ListPerPageProductTest.php @@ -14,7 +14,7 @@ class ListPerPageProductTest extends ApiTestCase public function test_list_per_page() { $this->server->setResponseOfPath( - '/'. ProductApi::PRODUCTS_URI, + '/' . ProductApi::PRODUCTS_URI, new ResponseStack( new Response($this->getFirstPage(), [], 200), new Response($this->getSecondPage(), [], 200) @@ -24,7 +24,10 @@ public function test_list_per_page() $api = $this->createClientByPassword()->getProductApi(); $firstPage = $api->listPerPage(10, true, []); - Assert::assertSame(['limit' => '10', 'with_count' => 'true'], $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_GET]); + Assert::assertSame( + ['limit' => '10', 'with_count' => 'true'], + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_GET] + ); Assert::assertInstanceOf(PageInterface::class, $firstPage); Assert::assertEquals(11, $firstPage->getCount()); @@ -32,7 +35,10 @@ public function test_list_per_page() Assert::assertNull($firstPage->getPreviousPage()); Assert::assertFalse($firstPage->hasPreviousPage()); Assert::assertTrue($firstPage->hasNextPage()); - Assert::assertSame($this->server->getServerRoot() . '/api/rest/v1/products?page=2&with_count=true&pagination_type=page&limit=10', $firstPage->getNextLink()); + Assert::assertSame( + $this->server->getServerRoot() . '/api/rest/v1/products?page=2&with_count=true&pagination_type=page&limit=10', + $firstPage->getNextLink() + ); Assert::assertEquals(10, count($firstPage->getItems())); $secondPage = $firstPage->getNextPage(); @@ -50,7 +56,10 @@ public function test_list_per_page() Assert::assertNull($secondPage->getNextPage()); Assert::assertFalse($secondPage->hasNextPage()); Assert::assertTrue($secondPage->hasPreviousPage()); - Assert::assertSame($this->server->getServerRoot() . '/api/rest/v1/products?page=1&with_count=true&pagination_type=page&limit=10', $secondPage->getPreviousLink()); + Assert::assertSame( + $this->server->getServerRoot() . '/api/rest/v1/products?page=1&with_count=true&pagination_type=page&limit=10', + $secondPage->getPreviousLink() + ); Assert::assertEquals(1, count($secondPage->getItems())); } diff --git a/tests/Api/ProductDraftUuid/GetProductDraftUuidIntegration.php b/tests/Api/ProductDraftUuid/GetProductDraftUuidIntegration.php index cffdc4eb..531b6303 100644 --- a/tests/Api/ProductDraftUuid/GetProductDraftUuidIntegration.php +++ b/tests/Api/ProductDraftUuid/GetProductDraftUuidIntegration.php @@ -19,7 +19,7 @@ class GetProductDraftUuidIntegration extends ApiTestCase public function test_get_product() { $this->server->setResponseOfPath( - '/'.sprintf(ProductDraftUuidApi::PRODUCT_DRAFT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), + '/' . sprintf(ProductDraftUuidApi::PRODUCT_DRAFT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), new ResponseStack( new Response($this->getProductDraft(), [], HttpClient::HTTP_OK) ) @@ -35,7 +35,7 @@ public function test_get_product() public function test_get_unknown_product() { $this->server->setResponseOfPath( - '/'.sprintf(ProductDraftUuidApi::PRODUCT_DRAFT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), + '/' . sprintf(ProductDraftUuidApi::PRODUCT_DRAFT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), new ResponseStack( new Response('{"code": 404, "message":"Resource `12951d98-210e-4bRC-ab18-7fdgf1bd14f3` does not exist."}', [], 404) ) diff --git a/tests/Api/ProductUuid/CreateProductUuidIntegration.php b/tests/Api/ProductUuid/CreateProductUuidIntegration.php index d9278435..51f8f8bb 100644 --- a/tests/Api/ProductUuid/CreateProductUuidIntegration.php +++ b/tests/Api/ProductUuid/CreateProductUuidIntegration.php @@ -20,7 +20,7 @@ class CreateProductUuidIntegration extends ApiTestCase public function test_create_product() { $this->server->setResponseOfPath( - '/'.ProductUuidApi::PRODUCTS_UUID_URI, + '/' . ProductUuidApi::PRODUCTS_UUID_URI, new ResponseStack( new Response('', [], HttpClient::HTTP_CREATED) ) @@ -40,7 +40,7 @@ public function test_create_product() public function test_create_invalid_product() { $this->server->setResponseOfPath( - '/'.ProductUuidApi::PRODUCTS_UUID_URI, + '/' . ProductUuidApi::PRODUCTS_UUID_URI, new ResponseStack( new Response( '{"code": 422, "message":"The value 12951d98-210e-4bRC-ab18-7fdgf1bd14f3 is already set on another product for the uuid"}', diff --git a/tests/Api/ProductUuid/DeleteProductUuidIntegration.php b/tests/Api/ProductUuid/DeleteProductUuidIntegration.php index 3059c517..3bf2337f 100644 --- a/tests/Api/ProductUuid/DeleteProductUuidIntegration.php +++ b/tests/Api/ProductUuid/DeleteProductUuidIntegration.php @@ -19,7 +19,7 @@ class DeleteProductUuidIntegration extends ApiTestCase public function test_create_product() { $this->server->setResponseOfPath( - '/'. sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), + '/' . sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), new ResponseStack( new Response('', [], HttpClient::HTTP_NO_CONTENT) ) diff --git a/tests/Api/ProductUuid/GetProductUuidIntegration.php b/tests/Api/ProductUuid/GetProductUuidIntegration.php index b9ca786f..84f08288 100644 --- a/tests/Api/ProductUuid/GetProductUuidIntegration.php +++ b/tests/Api/ProductUuid/GetProductUuidIntegration.php @@ -19,7 +19,7 @@ class GetProductUuidIntegration extends ApiTestCase public function test_get_product() { $this->server->setResponseOfPath( - '/'.sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), + '/' . sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), new ResponseStack( new Response($this->getProduct(), [], HttpClient::HTTP_OK) ) @@ -35,7 +35,7 @@ public function test_get_product() public function test_get_unknown_product() { $this->server->setResponseOfPath( - '/'.sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), + '/' . sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), new ResponseStack( new Response('{"code": 404, "message":"Resource `12951d98-210e-4bRC-ab18-7fdgf1bd14f3` does not exist."}', [], 404) ) diff --git a/tests/Api/ProductUuid/ListPerPageProductUuidIntegration.php b/tests/Api/ProductUuid/ListPerPageProductUuidIntegration.php index 5def2bb9..5a64ca5d 100644 --- a/tests/Api/ProductUuid/ListPerPageProductUuidIntegration.php +++ b/tests/Api/ProductUuid/ListPerPageProductUuidIntegration.php @@ -2,7 +2,6 @@ namespace Akeneo\Pim\ApiClient\tests\Api\ProductUuid; - use Akeneo\Pim\ApiClient\Api\ProductUuidApi; use Akeneo\Pim\ApiClient\Client\HttpClient; use Akeneo\Pim\ApiClient\Pagination\PageInterface; @@ -21,7 +20,7 @@ class ListPerPageProductUuidIntegration extends ApiTestCase public function test_list_per_page() { $this->server->setResponseOfPath( - '/'. ProductUuidApi::PRODUCTS_UUID_URI, + '/' . ProductUuidApi::PRODUCTS_UUID_URI, new ResponseStack( new Response($this->getFirstPage(), [], HttpClient::HTTP_OK), new Response($this->getSecondPage(), [], HttpClient::HTTP_OK) @@ -31,8 +30,10 @@ public function test_list_per_page() $api = $this->createClientByPassword()->getProductUuidApi(); $firstPage = $api->listPerPage(10, true, []); - Assert::assertSame(['limit' => '10', 'with_count' => 'true'], - $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_GET]); + Assert::assertSame( + ['limit' => '10', 'with_count' => 'true'], + $this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_GET] + ); Assert::assertInstanceOf(PageInterface::class, $firstPage); Assert::assertEquals(11, $firstPage->getCount()); @@ -40,7 +41,10 @@ public function test_list_per_page() Assert::assertNull($firstPage->getPreviousPage()); Assert::assertFalse($firstPage->hasPreviousPage()); Assert::assertTrue($firstPage->hasNextPage()); - Assert::assertSame($this->server->getServerRoot() . '/api/rest/v1/products-uuid?page=2&with_count=true&pagination_type=page&limit=10', $firstPage->getNextLink()); + Assert::assertSame( + $this->server->getServerRoot() . '/api/rest/v1/products-uuid?page=2&with_count=true&pagination_type=page&limit=10', + $firstPage->getNextLink() + ); Assert::assertCount(10, $firstPage->getItems()); $secondPage = $firstPage->getNextPage(); @@ -58,7 +62,10 @@ public function test_list_per_page() Assert::assertNull($secondPage->getNextPage()); Assert::assertFalse($secondPage->hasNextPage()); Assert::assertTrue($secondPage->hasPreviousPage()); - Assert::assertSame($this->server->getServerRoot() . '/api/rest/v1/products-uuid?page=1&with_count=true&pagination_type=page&limit=10', $secondPage->getPreviousLink()); + Assert::assertSame( + $this->server->getServerRoot() . '/api/rest/v1/products-uuid?page=1&with_count=true&pagination_type=page&limit=10', + $secondPage->getPreviousLink() + ); Assert::assertCount(1, $secondPage->getItems()); } diff --git a/tests/Api/ProductUuid/UpsertListProductUuidIntegration.php b/tests/Api/ProductUuid/UpsertListProductUuidIntegration.php index cfdc2dd1..20870cd3 100644 --- a/tests/Api/ProductUuid/UpsertListProductUuidIntegration.php +++ b/tests/Api/ProductUuid/UpsertListProductUuidIntegration.php @@ -21,7 +21,7 @@ public function setUp(): void { parent::setUp(); $this->server->setResponseOfPath( - '/'.ProductUuidApi::PRODUCTS_UUID_URI, + '/' . ProductUuidApi::PRODUCTS_UUID_URI, new ResponseStack( new Response($this->getResults(), [], HttpClient::HTTP_OK) ) diff --git a/tests/Api/ProductUuid/UpsertProductUuidIntegration.php b/tests/Api/ProductUuid/UpsertProductUuidIntegration.php index 6e4b1b81..5266c49a 100644 --- a/tests/Api/ProductUuid/UpsertProductUuidIntegration.php +++ b/tests/Api/ProductUuid/UpsertProductUuidIntegration.php @@ -19,7 +19,7 @@ class UpsertProductUuidIntegration extends ApiTestCase public function test_upsert_product() { $this->server->setResponseOfPath( - '/'. sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), + '/' . sprintf(ProductUuidApi::PRODUCT_UUID_URI, '12951d98-210e-4bRC-ab18-7fdgf1bd14f3'), new ResponseStack( new Response('', [], HttpClient::HTTP_NO_CONTENT) ) @@ -30,12 +30,12 @@ public function test_upsert_product() $parameters = [ 'identifier' => 'black_docks', 'enabled' => false, - 'values' => [ + 'values' => [ 'name' => [ [ 'locale' => 'en_US', - 'scope' => null, - 'data' => 'Black Docks', + 'scope' => null, + 'data' => 'Black Docks', ], ], ] @@ -46,5 +46,4 @@ public function test_upsert_product() Assert::assertSame(HttpClient::HTTP_NO_CONTENT, $response); } - } diff --git a/tests/Api/ReferenceEntity/GetReferenceEntityIntegration.php b/tests/Api/ReferenceEntity/GetReferenceEntityIntegration.php index b4289a96..9ba52743 100644 --- a/tests/Api/ReferenceEntity/GetReferenceEntityIntegration.php +++ b/tests/Api/ReferenceEntity/GetReferenceEntityIntegration.php @@ -16,7 +16,7 @@ class GetReferenceEntityIntegration extends ApiTestCase public function test_get_reference_entity() { $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityApi::REFERENCE_ENTITY_URI, 'brand'), + '/' . sprintf(ReferenceEntityApi::REFERENCE_ENTITY_URI, 'brand'), new ResponseStack( new Response($this->getBrand(), [], 200) ) @@ -32,7 +32,7 @@ public function test_get_reference_entity() public function test_get_unknown_reference_entity() { $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityApi::REFERENCE_ENTITY_URI, 'foo'), + '/' . sprintf(ReferenceEntityApi::REFERENCE_ENTITY_URI, 'foo'), new ResponseStack( new Response('{"code": 404, "message":"Reference entity \"foo\" does not exist."}', [], 404) ) diff --git a/tests/Api/ReferenceEntity/ListAllReferenceEntitiesIntegration.php b/tests/Api/ReferenceEntity/ListAllReferenceEntitiesIntegration.php index d9c6f70e..4168af51 100644 --- a/tests/Api/ReferenceEntity/ListAllReferenceEntitiesIntegration.php +++ b/tests/Api/ReferenceEntity/ListAllReferenceEntitiesIntegration.php @@ -15,7 +15,7 @@ class ListAllReferenceEntitiesIntegration extends ApiTestCase public function test_list_per_page() { $this->server->setResponseOfPath( - '/'. ReferenceEntityApi::REFERENCE_ENTITIES_URI, + '/' . ReferenceEntityApi::REFERENCE_ENTITIES_URI, new ResponseStack( new Response($this->getFirstPage(), [], 200), new Response($this->getSecondPage(), [], 200) @@ -82,7 +82,6 @@ private function getFirstPage(): string } } JSON; - } private function getSecondPage(): string @@ -120,6 +119,5 @@ private function getSecondPage(): string } } JSON; - } } diff --git a/tests/Api/ReferenceEntity/UpsertReferenceEntityIntegration.php b/tests/Api/ReferenceEntity/UpsertReferenceEntityIntegration.php index 940056c6..a9f96d3c 100644 --- a/tests/Api/ReferenceEntity/UpsertReferenceEntityIntegration.php +++ b/tests/Api/ReferenceEntity/UpsertReferenceEntityIntegration.php @@ -14,7 +14,7 @@ class UpsertReferenceEntityIntegration extends ApiTestCase public function test_upsert_reference_entity() { $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityApi::REFERENCE_ENTITY_URI, 'brand'), + '/' . sprintf(ReferenceEntityApi::REFERENCE_ENTITY_URI, 'brand'), new ResponseStack( new Response('', [], 204) ) diff --git a/tests/Api/ReferenceEntityRecord/GetReferenceEntityRecordIntegration.php b/tests/Api/ReferenceEntityRecord/GetReferenceEntityRecordIntegration.php index 7a4d94c3..3576a69d 100644 --- a/tests/Api/ReferenceEntityRecord/GetReferenceEntityRecordIntegration.php +++ b/tests/Api/ReferenceEntityRecord/GetReferenceEntityRecordIntegration.php @@ -16,7 +16,7 @@ class GetReferenceEntityRecordIntegration extends ApiTestCase public function test_get_reference_entity_record() { $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'designer', 'starck'), + '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'designer', 'starck'), new ResponseStack( new Response($this->getStarckRecord(), [], 200) ) @@ -34,7 +34,7 @@ public function test_get_unknow_product() $this->expectExceptionMessage("Record \"foo\" does not exist for the reference entity \"designer\"."); $this->expectException(\Akeneo\Pim\ApiClient\Exception\NotFoundHttpException::class); $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'designer', 'foo'), + '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'designer', 'foo'), new ResponseStack( new Response('{"code": 404, "message":"Record \"foo\" does not exist for the reference entity \"designer\"."}', [], 404) ) diff --git a/tests/Api/ReferenceEntityRecord/ListAllReferenceEntityRecordsIntegration.php b/tests/Api/ReferenceEntityRecord/ListAllReferenceEntityRecordsIntegration.php index 336bcda1..d1a6d7dd 100644 --- a/tests/Api/ReferenceEntityRecord/ListAllReferenceEntityRecordsIntegration.php +++ b/tests/Api/ReferenceEntityRecord/ListAllReferenceEntityRecordsIntegration.php @@ -15,7 +15,7 @@ class ListAllReferenceEntityRecordsIntegration extends ApiTestCase public function test_list_per_page() { $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORDS_URI, 'designer'), + '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORDS_URI, 'designer'), new ResponseStack( new Response($this->getFirstPage(), [], 200), new Response($this->getSecondPage(), [], 200) @@ -86,7 +86,6 @@ private function getFirstPage(): string } } JSON; - } private function getSecondPage(): string @@ -126,6 +125,5 @@ private function getSecondPage(): string } } JSON; - } } diff --git a/tests/Api/ReferenceEntityRecord/UpsertListReferenceEntityRecordIntegration.php b/tests/Api/ReferenceEntityRecord/UpsertListReferenceEntityRecordIntegration.php index ab5d32c1..8f11902a 100644 --- a/tests/Api/ReferenceEntityRecord/UpsertListReferenceEntityRecordIntegration.php +++ b/tests/Api/ReferenceEntityRecord/UpsertListReferenceEntityRecordIntegration.php @@ -27,7 +27,7 @@ public function test_upsert_a_list_of_reference_entity_records() JSON; $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORDS_URI, 'designer'), + '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORDS_URI, 'designer'), new ResponseStack( new Response($responseBody, [], 200) ) @@ -40,8 +40,8 @@ public function test_upsert_a_list_of_reference_entity_records() 'label' => [ [ 'channel' => null, - 'locale' => 'en_US', - 'data' => 'Philippe Starck' + 'locale' => 'en_US', + 'data' => 'Philippe Starck' ], ] ] @@ -52,8 +52,8 @@ public function test_upsert_a_list_of_reference_entity_records() 'label' => [ [ 'channel' => null, - 'locale' => 'en_US', - 'data' => 'James Dyson' + 'locale' => 'en_US', + 'data' => 'James Dyson' ], ] ] @@ -63,11 +63,11 @@ public function test_upsert_a_list_of_reference_entity_records() $expectedResponses = [ [ 'code' => 'starck', - 'status_code' =>204 + 'status_code' => 204 ], [ 'code' => 'dyson', - 'status_code' =>201 + 'status_code' => 201 ], ]; diff --git a/tests/Api/ReferenceEntityRecord/UpsertReferenceEntityRecordIntegration.php b/tests/Api/ReferenceEntityRecord/UpsertReferenceEntityRecordIntegration.php index e7e12048..764523d4 100644 --- a/tests/Api/ReferenceEntityRecord/UpsertReferenceEntityRecordIntegration.php +++ b/tests/Api/ReferenceEntityRecord/UpsertReferenceEntityRecordIntegration.php @@ -14,7 +14,7 @@ class UpsertReferenceEntityRecordIntegration extends ApiTestCase public function test_upsert_reference_entity_record() { $this->server->setResponseOfPath( - '/'. sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'designer', 'starck'), + '/' . sprintf(ReferenceEntityRecordApi::REFERENCE_ENTITY_RECORD_URI, 'designer', 'starck'), new ResponseStack( new Response('', [], 204) ) @@ -26,8 +26,8 @@ public function test_upsert_reference_entity_record() 'label' => [ [ 'channel' => null, - 'locale' => 'en_US', - 'data' => 'Philippe Starck' + 'locale' => 'en_US', + 'data' => 'Philippe Starck' ], ] ] diff --git a/tests/Api/UpsertListProductTest.php b/tests/Api/UpsertListProductTest.php index 138a0e20..ecad688b 100644 --- a/tests/Api/UpsertListProductTest.php +++ b/tests/Api/UpsertListProductTest.php @@ -15,7 +15,7 @@ public function setUp(): void { parent::setUp(); $this->server->setResponseOfPath( - '/'. ProductApi::PRODUCTS_URI, + '/' . ProductApi::PRODUCTS_URI, new ResponseStack( new Response($this->getResults(), [], 200) ) @@ -35,14 +35,14 @@ public function test_upsert_list() Assert::assertCount(2, $responseLines); Assert::assertSame([ - 'line' => 1, - 'identifier' => 'docks_black', + 'line' => 1, + 'identifier' => 'docks_black', 'status_code' => 204, ], $responseLines[1]); Assert::assertSame([ - 'line' => 2, - 'identifier' => 'pumps', + 'line' => 2, + 'identifier' => 'pumps', 'status_code' => 201, ], $responseLines[2]); } @@ -65,14 +65,14 @@ public function test_upsert_list_from_stream() Assert::assertCount(2, $responseLines); Assert::assertSame([ - 'line' => 1, - 'identifier' => 'docks_black', + 'line' => 1, + 'identifier' => 'docks_black', 'status_code' => 204, ], $responseLines[1]); Assert::assertSame([ - 'line' => 2, - 'identifier' => 'pumps', + 'line' => 2, + 'identifier' => 'pumps', 'status_code' => 201, ], $responseLines[2]); } @@ -90,33 +90,33 @@ private function getProductToUpsert(): array return [ [ 'identifier' => 'docks_black', - 'enabled' => false, - 'values' => [ + 'enabled' => false, + 'values' => [ 'name' => [ [ 'locale' => 'en_US', - 'scope' => null, - 'data' => 'Black Docks', + 'scope' => null, + 'data' => 'Black Docks', ], ], ] ], [ 'identifier' => 'pumps', - 'enabled' => false, - 'family' => 'sandals', + 'enabled' => false, + 'family' => 'sandals', 'categories' => ['summer_collection'], - 'values' => [ + 'values' => [ 'name' => [ [ - 'data' => 'The pumps', + 'data' => 'The pumps', 'locale' => 'en_US', - 'scope' => null, + 'scope' => null, ], [ - 'data' => 'Les pumps', + 'data' => 'Les pumps', 'locale' => 'fr_FR', - 'scope' => null, + 'scope' => null, ] ], ] @@ -131,5 +131,4 @@ private function getResults(): string {"line": 2,"identifier": "pumps","status_code": 201} JSON; } - } diff --git a/tests/Api/UpsertProductTest.php b/tests/Api/UpsertProductTest.php index 01172c26..f522bec1 100644 --- a/tests/Api/UpsertProductTest.php +++ b/tests/Api/UpsertProductTest.php @@ -13,7 +13,7 @@ class UpsertProductTest extends ApiTestCase public function test_upsert_product() { $this->server->setResponseOfPath( - '/'. sprintf(ProductApi::PRODUCT_URI, 'docks_black'), + '/' . sprintf(ProductApi::PRODUCT_URI, 'docks_black'), new ResponseStack( new Response('', [], 204) ) @@ -23,12 +23,12 @@ public function test_upsert_product() $parameters = [ 'enabled' => false, - 'values' => [ + 'values' => [ 'name' => [ [ 'locale' => 'en_US', - 'scope' => null, - 'data' => 'Black Docks', + 'scope' => null, + 'data' => 'Black Docks', ], ], ] @@ -39,5 +39,4 @@ public function test_upsert_product() Assert::assertSame(204, $response); } - } diff --git a/tests/Cache/AkeneoPimClientBuilderTest.php b/tests/Cache/AkeneoPimClientBuilderTest.php index 75e23fef..09a720cf 100644 --- a/tests/Cache/AkeneoPimClientBuilderTest.php +++ b/tests/Cache/AkeneoPimClientBuilderTest.php @@ -1,4 +1,5 @@ server->setResponseOfPath( - '/'.sprintf(ProductApi::PRODUCT_URI, 'black_sneakers'), + '/' . sprintf(ProductApi::PRODUCT_URI, 'black_sneakers'), new ResponseStack( new Response($this->getProduct(), [], 200) ) diff --git a/tests/Cache/LRUCacheTest.php b/tests/Cache/LRUCacheTest.php index f1d8a639..1b703be8 100644 --- a/tests/Cache/LRUCacheTest.php +++ b/tests/Cache/LRUCacheTest.php @@ -39,4 +39,4 @@ public function testRemovesLru(): void $this->assertSame([4], $cache->get('d')); $this->assertSame([5], $cache->get('e')); } -} \ No newline at end of file +} diff --git a/tests/Client/CachedResourceClientTest.php b/tests/Client/CachedResourceClientTest.php index 849bb78a..443a0a6a 100644 --- a/tests/Client/CachedResourceClientTest.php +++ b/tests/Client/CachedResourceClientTest.php @@ -19,7 +19,7 @@ public function test_get_cached_resource(): void $uri = 'uri'; $uriParameters = ['uriParameter']; - $cacheKey = md5($uri.implode('', $uriParameters)); + $cacheKey = md5($uri . implode('', $uriParameters)); $mockCache ->expects(self::exactly(2)) @@ -42,4 +42,4 @@ public function test_get_cached_resource(): void self::assertSame(['resource'], $cachedResourceClient->getResource($uri, $uriParameters)); self::assertSame(['cachedValue'], $cachedResourceClient->getResource($uri, $uriParameters)); } -} \ No newline at end of file +}