diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87df9077..06bc4ab1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,28 +1,18 @@ -on: [push] +name: tests +on: [push, pull_request] + jobs: - build-and-test: - name: Build and test + phpunit: runs-on: ubuntu-latest + strategy: + matrix: + php: ['8.1', '8.2', '8.3', '8.4'] steps: - - name: checkout - uses: actions/checkout@v3 - - - name: install composer dependencies - uses: php-actions/composer@v6 - with: - php_version: 7.4 - -# - name: php-cs-fixer static analysis -# uses: docker://oskarstark/php-cs-fixer-ga -# with: -# args: --using-cache=no --diff --dry-run -v - - - name: PHPUnit Tests - uses: php-actions/phpunit@v3 + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: - version: 5 - php_version: 7.1 - bootstrap: vendor/autoload.php - configuration: phpunit.xml.dist - args: --coverage-text - + php-version: ${{ matrix.php }} + coverage: none + extensions: curl, mbstring, dom, simplexml + - run: composer install --no-interaction --prefer-dist + - run: vendor/bin/phpunit diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 9c7a34ea..00000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,32 +0,0 @@ - true, - 'visibility_required' => false, // PHP7.1+ - 'array_syntax' => false, // PHP5.4+ - 'phpdoc_summary' => false, - 'phpdoc_annotation_without_dot' => false, - 'no_superfluous_phpdoc_tags' => false, - 'yoda_style' => false, - 'concat_space' => array('spacing' => 'one'), - 'single_line_throw' => false, - 'phpdoc_to_comment' => false, - 'global_namespace_import' => true, -); -$config->setRules($rules); - -/** @var Finder $finder */ -$finder = $config - ->setUsingCache(true) - ->getFinder(); - -$finder - ->in(__DIR__ . '/src') - ->in(__DIR__ . '/tests') - ->notName('tijsverkoyen_classes.php') - ->sortByName(); - -return $config; diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index cbe20fa2..00000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,19 +0,0 @@ -checks: - php: - code_rating: true - duplication: true - -build: - nodes: - analysis: - tests: - override: - - php-scrutinizer-run - - tests: - override: - - - command: 'phpunit' - coverage: - file: tests/reports/coverage-clover.xml - format: php-clover diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f42fde43..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php - -php: - - '5.3' - - '5.4' - - '5.5' - - '5.6' - - '7.0' - - '7.1' - - '7.2' - - '7.3' - - '7.4' - - '8.0' - -before_install: - - composer self-update - -install: - - composer install --no-dev - -script: - - phpunit --coverage-clover=coverage.clover diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 536810a2..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,83 +0,0 @@ -# Changelog - -### 3.4.11 - -* Fix previously broken unit tests -* Add github-actions -* Format code by following PSR-12 - -### 3.4.10 - -* throw BpostInvalidXmlResponseException if XML response if not a valid XML - -### 3.4.9 - -* Geo6.php supports Country -* Fix string/int comparison in ApiCaller -Add PHP7.1 -> 8.0 to travis CI job - -### 3.4.8 - -* Update version of some composer packages - -### 3.4.7 - -* Endpoint change for Geo6/Pudo - -### 3.4.6 - -* For National, option Insured must call class Insurance -* Fixed the parcel locker 'unregistered', UnregisteredParceLockerMember is deprecated #16 - -### 3.4.5 - -* Fix PHP signatures - -### 3.4.1 - -* Refactoring -* Fix issues - -### 3.4.0 - -* Add retro-compatibility with tijsverkoyen library (namespace changes) -* Complete the README (examples, broken links, ...) -* Change API URL (api.bpost.be -> api-parcel.bpost.be) -* Labels features - * Possibility to append field "order reference" - * Possibility to force printing -* Geo6 features - * Geo6 is now called via HTTPS - * Send data to API via POST - * Add Geo6::getPointType() to calculate point types -* Products features - * Add "bpack World Easy Return" to international products - * Box At247 can contain a product bpack 24/7 - -### 3.3.0 - -* Use bpost API version 3.3 (yet, bpack part only) -* Change namespace TijsVerkoyen\Bpost to Bpost\BpostApiClient -* Add more unit tests to perform code coverage -* Begin to based the unit tests on XML examples [given by bpost](http://bpost.freshdesk.com/support/solutions/articles/4000037653-where-can-i-find-the-bpack-integration-manual-examples-and-xsd-s-) -* Add CONTRIBUTING.md - -### 3.0.1 - -* Allowed SaturdayDelivery, see https://github.com/tijsverkoyen/bpost/pull/11 - -### 3.0.0 - -* Bugfix: removed usage of undefined constant, see https://github.com/tijsverkoyen/bpost/pull/8 - - -### 1.0.1 - -* Made the classes compliant with PSR -* Using Namespaces -* From now on we will follow the versionnumbers that bpost is using, so we will - skip a major version -* Introduction of the GEO-services -* Introduction of the Bpack24/7-services -* Composer support -* Decent objects diff --git a/composer.json b/composer.json index 90a676a7..c8c8c88c 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,5 @@ { "name": "zangra/bpost-api-library", - "version": "4.5.7", "type": "library", "description": "bpost API library is a PHP library to communicate with the bpost API.", "homepage": "https://github.com/Antidot-be/bpost-api-library", @@ -28,24 +27,26 @@ } ], "require": { - "php": ">=5.3.0", + "php": "^8.1 || ^8.4", + "psr/log": "^1.0 || ^2.0 || ^3.0", "ext-curl": "*", "ext-mbstring": "*", - "psr/log": "*", "ext-dom": "*", - "ext-SimpleXML": "*" + "ext-simplexml": "*" }, "require-dev": { - "phpunit/phpunit": "^5", - "friendsofphp/php-cs-fixer": "=3.9.5" + "phpunit/phpunit": "^11.2" }, "autoload": { "psr-4": { - "Bpost\\BpostApiClient\\": "src/", + "Bpost\\BpostApiClient\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { "Tests\\": "tests/" - }, - "classmap": [ - "src/tijsverkoyen_classes.php" - ] - } -} + } + }, + + "config": { "sort-packages": true } +} \ No newline at end of file diff --git a/composer.lock b/composer.lock deleted file mode 100644 index bcc80f38..00000000 --- a/composer.lock +++ /dev/null @@ -1,3594 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "1b1bff2cd4a73d46c06aed09ec84fb42", - "packages": [ - { - "name": "psr/log", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" - }, - "time": "2021-05-03T11:20:27+00:00" - } - ], - "packages-dev": [ - { - "name": "composer/pcre", - "version": "3.1.0", - "source": { - "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.3", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Pcre\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", - "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" - ], - "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-11-17T09:50:14+00:00" - }, - { - "name": "composer/semver", - "version": "3.3.2", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.4", - "symfony/phpunit-bridge": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.2" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-04-01T19:23:25+00:00" - }, - { - "name": "composer/xdebug-handler", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "ced299686f41dce890debac69273b47ffe98a40c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", - "reference": "ced299686f41dce890debac69273b47ffe98a40c", - "shasum": "" - }, - "require": { - "composer/pcre": "^1 || ^2 || ^3", - "php": "^7.2.5 || ^8.0", - "psr/log": "^1 || ^2 || ^3" - }, - "require-dev": { - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Composer\\XdebugHandler\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], - "description": "Restarts a process without Xdebug.", - "keywords": [ - "Xdebug", - "performance" - ], - "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-02-25T21:32:43+00:00" - }, - { - "name": "doctrine/annotations", - "version": "1.13.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "648b0343343565c4a056bfc8392201385e8d89f0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/648b0343343565c4a056bfc8392201385e8d89f0", - "reference": "648b0343343565c4a056bfc8392201385e8d89f0", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "ext-tokenizer": "*", - "php": "^7.1 || ^8.0", - "psr/cache": "^1 || ^2 || ^3" - }, - "require-dev": { - "doctrine/cache": "^1.11 || ^2.0", - "doctrine/coding-standard": "^6.0 || ^8.1", - "phpstan/phpstan": "^1.4.10 || ^1.8.0", - "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", - "symfony/cache": "^4.4 || ^5.2", - "vimeo/psalm": "^4.10" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "https://www.doctrine-project.org/projects/annotations.html", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "support": { - "issues": "https://github.com/doctrine/annotations/issues", - "source": "https://github.com/doctrine/annotations/tree/1.13.3" - }, - "time": "2022-07-02T10:48:51+00:00" - }, - { - "name": "doctrine/instantiator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2022-03-03T08:28:38+00:00" - }, - { - "name": "doctrine/lexer", - "version": "1.2.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/c268e882d4dbdd85e36e4ad69e02dc284f89d229", - "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9.0", - "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.11" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "https://www.doctrine-project.org/projects/lexer.html", - "keywords": [ - "annotations", - "docblock", - "lexer", - "parser", - "php" - ], - "support": { - "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/1.2.3" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", - "type": "tidelift" - } - ], - "time": "2022-02-28T11:07:21+00:00" - }, - { - "name": "friendsofphp/php-cs-fixer", - "version": "v3.9.5", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "4465d70ba776806857a1ac2a6f877e582445ff36" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/4465d70ba776806857a1ac2a6f877e582445ff36", - "reference": "4465d70ba776806857a1ac2a6f877e582445ff36", - "shasum": "" - }, - "require": { - "composer/semver": "^3.2", - "composer/xdebug-handler": "^3.0.3", - "doctrine/annotations": "^1.13", - "ext-json": "*", - "ext-tokenizer": "*", - "php": "^7.4 || ^8.0", - "php-cs-fixer/diff": "^2.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/filesystem": "^5.4 || ^6.0", - "symfony/finder": "^5.4 || ^6.0", - "symfony/options-resolver": "^5.4 || ^6.0", - "symfony/polyfill-mbstring": "^1.23", - "symfony/polyfill-php80": "^1.25", - "symfony/polyfill-php81": "^1.25", - "symfony/process": "^5.4 || ^6.0", - "symfony/stopwatch": "^5.4 || ^6.0" - }, - "require-dev": { - "justinrainbow/json-schema": "^5.2", - "keradus/cli-executor": "^1.5", - "mikey179/vfsstream": "^1.6.10", - "php-coveralls/php-coveralls": "^2.5.2", - "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", - "phpspec/prophecy": "^1.15", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", - "phpunitgoodpractices/polyfill": "^1.5", - "phpunitgoodpractices/traits": "^1.9.1", - "symfony/phpunit-bridge": "^6.0", - "symfony/yaml": "^5.4 || ^6.0" - }, - "suggest": { - "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters." - }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", - "autoload": { - "psr-4": { - "PhpCsFixer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - } - ], - "description": "A tool to automatically fix PHP code style", - "support": { - "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", - "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.9.5" - }, - "funding": [ - { - "url": "https://github.com/keradus", - "type": "github" - } - ], - "time": "2022-07-22T08:43:51+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" - }, - "require-dev": { - "doctrine/collections": "^1.6.8", - "doctrine/common": "^2.13.3 || ^3.2.2", - "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" - }, - "type": "library", - "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" - }, - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2022-03-03T13:19:32+00:00" - }, - { - "name": "php-cs-fixer/diff", - "version": "v2.0.2", - "source": { - "type": "git", - "url": "https://github.com/PHP-CS-Fixer/diff.git", - "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/29dc0d507e838c4580d018bd8b5cb412474f7ec3", - "reference": "29dc0d507e838c4580d018bd8b5cb412474f7ec3", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", - "symfony/process": "^3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "sebastian/diff v3 backport support for PHP 5.6+", - "homepage": "https://github.com/PHP-CS-Fixer", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/PHP-CS-Fixer/diff/issues", - "source": "https://github.com/PHP-CS-Fixer/diff/tree/v2.0.2" - }, - "abandoned": true, - "time": "2020-10-14T08:32:19+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.6.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "rector/rector": "^0.13.9", - "vimeo/psalm": "^4.25" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" - }, - "time": "2022-10-14T12:47:21+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.10.3", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" - }, - "time": "2020-03-05T15:02:03+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "4.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" - }, - "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" - }, - "suggest": { - "ext-xdebug": "^2.5.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/4.0" - }, - "time": "2017-04-02T07:44:40+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5" - }, - "time": "2017-11-27T13:52:08+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" - }, - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/master" - }, - "time": "2017-02-26T11:10:40+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "791198a2c6254db10131eecfe8c06670700904db" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", - "reference": "791198a2c6254db10131eecfe8c06670700904db", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" - }, - "abandoned": true, - "time": "2017-11-27T05:48:46+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "5.7.27", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.4", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "^1.0.6|^2.0.1", - "symfony/yaml": "~2.1|~3.0|~4.0" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.7.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/5.7.27" - }, - "time": "2018-02-01T05:50:59+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", - "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/3.4" - }, - "abandoned": true, - "time": "2017-06-30T09:13:00+00:00" - }, - { - "name": "psr/cache", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/master" - }, - "time": "2016-08-06T20:24:11+00:00" - }, - { - "name": "psr/container", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" - }, - "time": "2021-11-05T16:50:12+00:00" - }, - { - "name": "psr/event-dispatcher", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Standard interfaces for event handling.", - "keywords": [ - "events", - "psr", - "psr-14" - ], - "support": { - "issues": "https://github.com/php-fig/event-dispatcher/issues", - "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" - }, - "time": "2019-01-08T18:20:26+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T08:15:22+00:00" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/1.2" - }, - "time": "2017-01-29T09:50:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/1.4" - }, - "time": "2017-05-22T07:24:03+00:00" - }, - { - "name": "sebastian/environment", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/master" - }, - "time": "2016-11-26T07:53:53+00:00" - }, - { - "name": "sebastian/exporter", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/master" - }, - "time": "2016-11-19T08:54:04+00:00" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/1.1.1" - }, - "time": "2015-10-12T03:26:01+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/master" - }, - "time": "2017-02-18T15:18:39+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" - }, - "time": "2016-11-19T07:33:16+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/master" - }, - "time": "2015-07-28T20:34:47+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/master" - }, - "time": "2016-10-03T07:35:21+00:00" - }, - { - "name": "symfony/console", - "version": "v5.4.15", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ea59bb0edfaf9f28d18d8791410ee0355f317669", - "reference": "ea59bb0edfaf9f28d18d8791410ee0355f317669", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" - }, - "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" - }, - "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Eases the creation of beautiful and testable command line interfaces", - "homepage": "https://symfony.com", - "keywords": [ - "cli", - "command line", - "console", - "terminal" - ], - "support": { - "source": "https://github.com/symfony/console/tree/v5.4.15" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-10-26T21:41:52+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v5.4.9", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc", - "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/event-dispatcher-contracts": "^2|^3", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "symfony/dependency-injection": "<4.4" - }, - "provide": { - "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0" - }, - "require-dev": { - "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/stopwatch": "^4.4|^5.0|^6.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.9" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-05T16:45:39+00:00" - }, - { - "name": "symfony/event-dispatcher-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1", - "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/event-dispatcher": "^1" - }, - "suggest": { - "symfony/event-dispatcher-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to dispatching event", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v5.4.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "ac09569844a9109a5966b9438fc29113ce77cf51" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51", - "reference": "ac09569844a9109a5966b9438fc29113ce77cf51", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.13" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-09-21T19:53:16+00:00" - }, - { - "name": "symfony/finder", - "version": "v5.4.11", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "7872a66f57caffa2916a584db1aa7f12adc76f8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/7872a66f57caffa2916a584db1aa7f12adc76f8c", - "reference": "7872a66f57caffa2916a584db1aa7f12adc76f8c", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Finds files and directories via an intuitive fluent interface", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.11" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-07-29T07:37:50+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "v5.4.11", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "54f14e36aa73cb8f7261d7686691fd4d75ea2690" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/54f14e36aa73cb8f7261d7686691fd4d75ea2690", - "reference": "54f14e36aa73cb8f7261d7686691fd4d75ea2690", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.11" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-07-20T13:00:38+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-php81", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/process", - "version": "v5.4.11", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/6e75fe6874cbc7e4773d049616ab450eff537bf1", - "reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/v5.4.11" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-06-27T16:58:25+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" - }, - "conflict": { - "ext-psr": "<1.1|>=2" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-30T19:17:29+00:00" - }, - { - "name": "symfony/stopwatch", - "version": "v5.4.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6df7a3effde34d81717bbef4591e5ffe32226d69", - "reference": "6df7a3effde34d81717bbef4591e5ffe32226d69", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/service-contracts": "^1|^2|^3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides a way to profile code", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.13" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-09-28T13:19:49+00:00" - }, - { - "name": "symfony/string", - "version": "v5.4.15", - "source": { - "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", - "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" - }, - "conflict": { - "symfony/translation-contracts": ">=3.0" - }, - "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" - }, - "type": "library", - "autoload": { - "files": [ - "Resources/functions.php" - ], - "psr-4": { - "Symfony\\Component\\String\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", - "homepage": "https://symfony.com", - "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" - ], - "support": { - "source": "https://github.com/symfony/string/tree/v5.4.15" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-10-05T15:16:54+00:00" - }, - { - "name": "symfony/yaml", - "version": "v4.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "aeccc4dc52a9e634f1d1eebeb21eacfdcff1053d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/aeccc4dc52a9e634f1d1eebeb21eacfdcff1053d", - "reference": "aeccc4dc52a9e634f1d1eebeb21eacfdcff1053d", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "^3.4|^4.0|^5.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Loads and dumps YAML files", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v4.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-08-02T15:47:23+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "php": "^7.2 || ^8.0" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.11.0" - }, - "time": "2022-06-03T18:03:27+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.0", - "ext-curl": "*", - "ext-mbstring": "*", - "ext-dom": "*", - "ext-simplexml": "*" - }, - "platform-dev": [], - "plugin-api-version": "2.2.0" -} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 65d090b5..38d50c6a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,42 +1,35 @@ - - + + - + tests tests/connection-tests - - + + src - - - src/Bpack247.php - src/Bpost.php - src/Geo6.php - - - - - - - src - - tests/reports - - - + + + tests/reports + + src/Bpack247.php + src/Bpost.php + src/Geo6.php + + - - - + + + + + diff --git a/src/ApiCaller/ApiCaller.php b/src/ApiCaller/ApiCaller.php index 0c3283dd..a1875e40 100644 --- a/src/ApiCaller/ApiCaller.php +++ b/src/ApiCaller/ApiCaller.php @@ -1,14 +1,11 @@ logger = $logger; - } - - /** - * @return int - */ - public function getResponseHttpCode() + public function getResponseHttpCode(): ?int { return $this->responseHttpCode; } - /** - * @return string - */ - public function getResponseBody() + public function getResponseBody(): string { return $this->responseBody; } - /** - * @return string - */ - public function getResponseContentType() + public function getResponseContentType(): ?string { return $this->responseContentType; } /** - * @param array $options - * - * @return bool - * - * @throws BpostApiBusinessException - * @throws BpostApiResponseException - * @throws BpostApiSystemException * @throws BpostCurlException - * @throws BpostInvalidResponseException - * @throws BpostInvalidXmlResponseException */ - public function doCall(array $options) + public function doCall(array $options): bool { $curl = curl_init(); + if (!$curl instanceof \CurlHandle) { + throw new BpostCurlException('Unable to initialize cURL'); + } - // set options curl_setopt_array($curl, $options); $this->logger->debug('curl request', $options); - // execute - $this->responseBody = curl_exec($curl); - $errorNumber = curl_errno($curl); - $errorMessage = curl_error($curl); + try { + $result = curl_exec($curl); + $errno = curl_errno($curl); + $error = curl_error($curl); - $headers = curl_getinfo($curl); + $info = curl_getinfo($curl); // array - $this->logger->debug('curl response', array( - 'status' => $errorNumber . ' (' . $errorMessage . ')', - 'headers' => $headers, - 'response' => $this->responseBody, - )); + $this->logger->debug('curl response', [ + 'status' => $errno . ' (' . $error . ')', + 'headers' => $info, + 'response' => $result, + ]); - // error? - if ($errorNumber !== 0) { - throw new BpostCurlException($errorMessage, $errorNumber); - } + if ($errno !== 0) { + throw new BpostCurlException($error !== '' ? $error : 'cURL error', $errno); + } - if (isset($headers['http_code'])) { - $this->responseHttpCode = $headers['http_code']; - } + // seulement maintenant qu'on sait que ce n’est pas une erreur + $this->responseBody = is_string($result) ? $result : ''; - if (isset($headers['Content-Type'])) { - $this->responseContentType = $headers['Content-Type']; - } + $this->responseHttpCode = isset($info['http_code']) ? (int) $info['http_code'] : null; + $this->responseContentType = $info['content_type'] ?? null; - return true; + return true; + } finally { + curl_close($curl); + } } /** @@ -121,8 +89,8 @@ public function doCall(array $options) * * @return int */ - public function getHttpCodeType() + public function getHttpCodeType(): int { - return 100 * (int) ($this->responseHttpCode / 100); + return (int) (100 * floor($this->responseHttpCode / 100)); } } diff --git a/src/Bpack247.php b/src/Bpack247.php index 6a13358d..c57fa5f7 100644 --- a/src/Bpack247.php +++ b/src/Bpack247.php @@ -1,4 +1,5 @@ accountId = $accountId; + $this->passPhrase = $passPhrase; + } /** * Make the call * - * @param string $url The URL to call. - * @param string $body The data to pass. - * @param string $method The HTTP-method to use. - * - * @return SimpleXMLElement - * * @throws BpostApiBusinessException * @throws BpostApiSystemException * @throws BpostCurlException * @throws BpostInvalidResponseException */ - private function doCall($url, $body = null, $method = 'GET') + private function doCall(string $url, ?string $body = null, string $method = 'GET'): SimpleXMLElement { - // build Authorization header - $headers = array(); - $headers[] = 'Authorization: Basic ' . $this->getAuthorizationHeader(); - - // set options - $options = array(); - $options[CURLOPT_URL] = self::API_URL . $url; - $options[CURLOPT_USERAGENT] = $this->getUserAgent(); - $options[CURLOPT_RETURNTRANSFER] = true; - $options[CURLOPT_TIMEOUT] = (int) $this->getTimeOut(); - $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - $options[CURLOPT_HTTPHEADER] = $headers; - - if ($method == 'POST') { - $options[CURLOPT_POST] = true; - $options[CURLOPT_POSTFIELDS] = $body; + $headers = [ + 'Authorization: Basic ' . $this->getAuthorizationHeader(), + ]; + + $options = [ + CURLOPT_URL => self::API_URL . $url, + CURLOPT_USERAGENT => $this->getUserAgent(), + CURLOPT_RETURNTRANSFER => true, + CURLOPT_TIMEOUT => $this->getTimeOut(), + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_HTTPHEADER => $headers, + ]; + + if ($this->port !== null) { + $options[CURLOPT_PORT] = $this->port; } - // init - $this->curl = curl_init(); + if ($method === 'POST') { + $options[CURLOPT_POST] = true; + $options[CURLOPT_POSTFIELDS] = $body ?? ''; + } - // set options + $this->curl = curl_init(); curl_setopt_array($this->curl, $options); - // execute - $response = curl_exec($this->curl); - $headers = curl_getinfo($this->curl); + try { + $response = curl_exec($this->curl); + $info = curl_getinfo($this->curl); - // fetch errors - $errorNumber = curl_errno($this->curl); - $errorMessage = curl_error($this->curl); + $errorNumber = curl_errno($this->curl); + $errorMessage = curl_error($this->curl); - // error? - if ($errorNumber != '') { - throw new BpostCurlException($errorMessage, $errorNumber); - } + if ($errorNumber !== 0) { + throw new BpostCurlException($errorMessage, $errorNumber); + } + + $httpCode = (int)($info['http_code'] ?? 0); - // valid HTTP-code - if (!in_array($headers['http_code'], array(0, 200))) { - $xml = @simplexml_load_string($response); - - if ( - $xml !== false - && ($xml->getName() == 'businessException' || $xml->getName() == 'systemException') - ) { - $message = (string) $xml->message; - $code = isset($xml->code) ? (int) $xml->code : null; - switch ($xml->getName()) { - case 'businessException': + // Non 200 => tenter de parser l'erreur métier pour renvoyer l’exception dédiée + if (!in_array($httpCode, [0, 200], true)) { + $xml = @simplexml_load_string((string)$response); + + if ( + $xml !== false + && ($xml->getName() === 'businessException' || $xml->getName() === 'systemException') + ) { + $message = (string) ($xml->message ?? ''); + $code = isset($xml->code) ? (int) $xml->code : 0; + + if ($xml->getName() === 'businessException') { throw new BpostApiBusinessException($message, $code); - case 'systemException': - throw new BpostApiSystemException($message, $code); + } + throw new BpostApiSystemException($message, $code); } + + throw new BpostInvalidResponseException('', $httpCode); } - throw new BpostInvalidResponseException('', $headers['http_code']); - } + // 200: parser XML + $xml = simplexml_load_string((string)$response); + if ($xml === false) { + // pas de XML valide alors que 200 => considérer comme réponse invalide + throw new BpostInvalidResponseException('Empty or invalid XML body', 200); + } - // convert into XML - $xml = simplexml_load_string($response); + if ($xml->getName() === 'businessException') { + $message = (string) ($xml->message ?? ''); + $code = (int) ($xml->code ?? 0); + throw new BpostApiBusinessException($message, $code); + } - // validate - if ($xml->getName() == 'businessException') { - $message = (string) $xml->message; - $code = (string) $xml->code; - throw new BpostApiBusinessException($message, $code); + return $xml; + } finally { + if (is_resource($this->curl) || $this->curl instanceof CurlHandle) { + curl_close($this->curl); + } + $this->curl = null; } - - // return the response - return $xml; } /** * Generate the secret string for the Authorization header - * - * @return string */ - private function getAuthorizationHeader() + private function getAuthorizationHeader(): string { return base64_encode($this->accountId . ':' . $this->passPhrase); } /** - * Set the timeout - * After this time the request will stop. You should handle any errors triggered by this. - * - * @param int $seconds The timeout in seconds. + * After this time the request will stop. */ - public function setTimeOut($seconds) + public function setTimeOut(int $seconds): void { - $this->timeOut = (int) $seconds; + $this->timeOut = $seconds; } - /** - * Get the timeout that will be used - * - * @return int - */ - public function getTimeOut() + public function getTimeOut(): int { - return (int) $this->timeOut; + return $this->timeOut; } /** @@ -196,46 +168,28 @@ public function getTimeOut() * * @return string */ - public function getUserAgent() + public function getUserAgent(): string { - return (string) 'PHP Bpost Bpack247/' . self::VERSION . ' ' . $this->userAgent; + $extra = trim($this->userAgent); + return sprintf('PHP Bpost Bpack247/%s%s', self::VERSION, $extra !== '' ? ' ' . $extra : ''); } /** - * Set the user-agent for you application - * It will be appended to ours, the result will look like: "PHP Bpost/ " - * - * @param string $userAgent Your user-agent, it should look like /. - */ - public function setUserAgent($userAgent) - { - $this->userAgent = (string) $userAgent; - } - - /** - * Create Bpost instance - * - * @param string $accountId - * @param string $passPhrase + * Set your application user-agent, e.g. "MyApp/1.2.3" */ - public function __construct($accountId, $passPhrase) + public function setUserAgent(string $userAgent): void { - $this->accountId = (string) $accountId; - $this->passPhrase = (string) $passPhrase; + $this->userAgent = $userAgent; } - // webservice methods + // Webservice methods /** - * @param Customer $customer - * - * @return SimpleXMLElement - * * @throws BpostApiBusinessException * @throws BpostApiSystemException * @throws BpostCurlException * @throws BpostInvalidResponseException */ - public function createMember(Customer $customer) + public function createMember(Customer $customer): SimpleXMLElement { $url = '/customer'; @@ -243,38 +197,23 @@ public function createMember(Customer $customer) $document->preserveWhiteSpace = false; $document->formatOutput = true; - $document->appendChild( - $customer->toXML( - $document - ) - ); - - return $this->doCall( - $url, - $document->saveXML(), - 'POST' - ); + $document->appendChild($customer->toXML($document)); + + return $this->doCall($url, $document->saveXML(), 'POST'); } /** * Retrieve member information * - * @param string $id - * - * @return Customer - * * @throws BpostApiBusinessException * @throws BpostApiSystemException * @throws BpostCurlException * @throws BpostInvalidResponseException * @throws Exception\XmlException\BpostXmlNoUserIdFoundException */ - public function getMember($id) + public function getMember(string $id): Customer { - $xml = $this->doCall( - '/customer/' . $id - ); - + $xml = $this->doCall('/customer/' . $id); return Customer::createFromXML($xml); } -} +} \ No newline at end of file diff --git a/src/Bpack247/Customer.php b/src/Bpack247/Customer.php index 8d7e3659..51645d67 100644 --- a/src/Bpack247/Customer.php +++ b/src/Bpack247/Customer.php @@ -1,4 +1,5 @@ activated = $activated; } - /** - * @return bool - */ - public function getActivated() + public function getActivated(): ?bool { return $this->activated; } - /** - * @param string $companyName - */ - public function setCompanyName($companyName) + public function setCompanyName(?string $companyName): void { $this->companyName = $companyName; } - /** - * @return string - */ - public function getCompanyName() + public function getCompanyName(): ?string { return $this->companyName; } - /** - * @param DateTime $dateOfBirth - */ - public function setDateOfBirth($dateOfBirth) + public function setDateOfBirth(?DateTime $dateOfBirth): void { $this->dateOfBirth = $dateOfBirth; } - /** - * @return DateTime - */ - public function getDateOfBirth() + public function getDateOfBirth(): ?DateTime { return $this->dateOfBirth; } - /** - * @param string $deliveryCode - */ - public function setDeliveryCode($deliveryCode) + public function setDeliveryCode(?string $deliveryCode): void { $this->deliveryCode = $deliveryCode; } - /** - * @return string - */ - public function getDeliveryCode() + public function getDeliveryCode(): ?string { return $this->deliveryCode; } - /** - * @param string $email - */ - public function setEmail($email) + public function setEmail(?string $email): void { $this->email = $email; } - /** - * @return string - */ - public function getEmail() + public function getEmail(): ?string { return $this->email; } - /** - * @param string $firstName - */ - public function setFirstName($firstName) + public function setFirstName(?string $firstName): void { $this->firstName = $firstName; } - /** - * @return string - */ - public function getFirstName() + public function getFirstName(): ?string { return $this->firstName; } - /** - * @param bool $isComfortZoneUser - */ - public function setIsComfortZoneUser($isComfortZoneUser) + public function setIsComfortZoneUser(?bool $isComfortZoneUser): void { $this->isComfortZoneUser = $isComfortZoneUser; } - /** - * @return bool - */ - public function getIsComfortZoneUser() + public function getIsComfortZoneUser(): ?bool { return $this->isComfortZoneUser; } - /** - * @param string $lastName - */ - public function setLastName($lastName) + public function setLastName(?string $lastName): void { $this->lastName = $lastName; } - /** - * @return string - */ - public function getLastName() + public function getLastName(): ?string { return $this->lastName; } - /** - * @param string $mobileNumber - */ - public function setMobileNumber($mobileNumber) + public function setMobileNumber(?string $mobileNumber): void { $this->mobileNumber = $mobileNumber; } - /** - * @return string - */ - public function getMobileNumber() + public function getMobileNumber(): ?string { return $this->mobileNumber; } - /** - * @param string $mobilePrefix - */ - public function setMobilePrefix($mobilePrefix) + public function setMobilePrefix(string $mobilePrefix): void { $this->mobilePrefix = $mobilePrefix; } - /** - * @return string - */ - public function getMobilePrefix() + public function getMobilePrefix(): string { return $this->mobilePrefix; } - /** - * @param string $number - */ - public function setNumber($number) + public function setNumber(?string $number): void { $this->number = $number; } - /** - * @return string - */ - public function getNumber() + public function getNumber(): ?string { return $this->number; } - /** - * @param bool $optIn - */ - public function setOptIn($optIn) + public function setOptIn(?bool $optIn): void { $this->optIn = $optIn; } - /** - * @return bool - */ - public function getOptIn() + public function getOptIn(): ?bool { return $this->optIn; } - /** - * @param CustomerPackStation $packStation - */ - public function addPackStation(CustomerPackStation $packStation) + public function addPackStation(CustomerPackStation $packStation): void { $this->packStations[] = $packStation; } - /** - * @param array $packStations - */ - public function setPackStations($packStations) + public function setPackStations(array $packStations): void { $this->packStations = $packStations; } - /** - * @return array - */ - public function getPackStations() + public function getPackStations(): array { return $this->packStations; } - /** - * @param string $postalCode - */ - public function setPostalCode($postalCode) + public function setPostalCode(?string $postalCode): void { $this->postalCode = $postalCode; } - /** - * @return string - */ - public function getPostalCode() + public function getPostalCode(): ?string { return $this->postalCode; } /** - * @param string $preferredLanguage - * * @throws BpostInvalidValueException */ - public function setPreferredLanguage($preferredLanguage) + public function setPreferredLanguage(?string $preferredLanguage): void { - if (!in_array($preferredLanguage, self::getPossiblePreferredLanguageValues())) { - throw new BpostInvalidValueException( - 'preferred language', - $preferredLanguage, - self::getPossiblePreferredLanguageValues() - ); + if ($preferredLanguage === null) { + $this->preferredLanguage = null; + return; + } + if (!in_array($preferredLanguage, self::getPossiblePreferredLanguageValues(), true)) { + throw new BpostInvalidValueException('preferred language', $preferredLanguage, self::getPossiblePreferredLanguageValues()); } - $this->preferredLanguage = $preferredLanguage; } - /** - * @return string - */ - public function getPreferredLanguage() + public function getPreferredLanguage(): ?string { return $this->preferredLanguage; } - /** - * @return array - */ - public static function getPossiblePreferredLanguageValues() + public static function getPossiblePreferredLanguageValues(): array { - return array( + return [ self::CUSTOMER_PREFERRED_LANGUAGE_NL, self::CUSTOMER_PREFERRED_LANGUAGE_FR, self::CUSTOMER_PREFERRED_LANGUAGE_EN, - ); + ]; } - /** - * @param bool $receivePromotions - */ - public function setReceivePromotions($receivePromotions) + public function setReceivePromotions(?bool $receivePromotions): void { $this->receivePromotions = $receivePromotions; } - /** - * @return bool - */ - public function getReceivePromotions() + public function getReceivePromotions(): ?bool { return $this->receivePromotions; } - /** - * @param string $street - */ - public function setStreet($street) + public function setStreet(?string $street): void { $this->street = $street; } - /** - * @return string - */ - public function getStreet() + public function getStreet(): ?string { return $this->street; } /** - * @param string $title - * * @throws BpostInvalidValueException */ - public function setTitle($title) + public function setTitle(?string $title): void { - if (!in_array($title, self::getPossibleTitleValues())) { + if ($title === null) { + $this->title = null; + return; + } + if (!in_array($title, self::getPossibleTitleValues(), true)) { throw new BpostInvalidValueException('title', $title, self::getPossibleTitleValues()); } - $this->title = $title; } - /** - * @return string - */ - public function getTitle() + public function getTitle(): ?string { return $this->title; } - /** - * @return array - */ - public static function getPossibleTitleValues() + public static function getPossibleTitleValues(): array { - return array( + return [ self::CUSTOMER_TITLE_MR, self::CUSTOMER_TITLE_MS, - ); + ]; } - /** - * @param string $town - */ - public function setTown($town) + public function setTown(?string $town): void { $this->town = $town; } - /** - * @return string - */ - public function getTown() + public function getTown(): ?string { return $this->town; } - /** - * @param bool $useInformationForThirdParty - */ - public function setUseInformationForThirdParty($useInformationForThirdParty) + public function setUseInformationForThirdParty(?bool $useInformationForThirdParty): void { $this->useInformationForThirdParty = $useInformationForThirdParty; } - /** - * @return bool - */ - public function getUseInformationForThirdParty() + public function getUseInformationForThirdParty(): ?bool { return $this->useInformationForThirdParty; } - /** - * @param string $userID - */ - public function setUserID($userID) + public function setUserID(?string $userID): void { $this->userID = $userID; } - /** - * @return string - */ - public function getUserID() + public function getUserID(): ?string { return $this->userID; } - /** - * @param string $userName - */ - public function setUserName($userName) + public function setUserName(?string $userName): void { $this->userName = $userName; } - /** - * @return string - */ - public function getUserName() + public function getUserName(): ?string { return $this->userName; } - /** - * Return the object as an array for usage in the XML - * - * @param DOMDocument $document - * - * @return DOMElement - */ - public function toXML(DOMDocument $document) + public function toXML(DOMDocument $document): DOMElement { $customer = $document->createElement( 'Customer' @@ -570,14 +343,11 @@ public function toXML(DOMDocument $document) } /** - * @param SimpleXMLElement $xml - * - * @return Customer - * - * @throws BpostInvalidValueException + * @throws \DateMalformedStringException * @throws BpostXmlNoUserIdFoundException + * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): Customer { // @todo work with classmaps ... if (!isset($xml->UserID)) { @@ -637,17 +407,17 @@ public static function createFromXML(SimpleXMLElement $xml) ); } if (isset($xml->ReceivePromotions) && $xml->ReceivePromotions != '') { - $receivePromotions = in_array((string) $xml->ReceivePromotions, array('true', '1')); + $receivePromotions = in_array((string)$xml->ReceivePromotions, ['true','1'], true); $customer->setReceivePromotions($receivePromotions); } if (isset($xml->actived) && $xml->actived != '') { - $activated = in_array((string) $xml->actived, array('true', '1')); + $activated = in_array((string)$xml->actived, ['true','1'], true); $customer->setActivated($activated); } if (isset($xml->Title) && $xml->Title != '') { $title = (string) $xml->Title; $title = ucfirst(strtolower($title)); - if (substr($title, -1) != '.') { + if (!str_ends_with($title, '.')) { $title .= '.'; } @@ -666,11 +436,7 @@ public static function createFromXML(SimpleXMLElement $xml) return $customer; } - /** - * @param DOMDocument $document - * @param DOMElement $customer - */ - private function namingToXML(DOMDocument $document, DOMElement $customer) + private function namingToXML(DOMDocument $document, DOMElement $customer): void { if ($this->getFirstName() !== null) { $customer->appendChild( @@ -690,11 +456,7 @@ private function namingToXML(DOMDocument $document, DOMElement $customer) } } - /** - * @param DOMDocument $document - * @param DOMElement $customer - */ - private function contactToXML(DOMDocument $document, DOMElement $customer) + private function contactToXML(DOMDocument $document, DOMElement $customer): void { if ($this->getEmail() !== null) { $customer->appendChild( @@ -722,11 +484,7 @@ private function contactToXML(DOMDocument $document, DOMElement $customer) } } - /** - * @param DOMDocument $document - * @param DOMElement $customer - */ - private function addressToXML(DOMDocument $document, DOMElement $customer) + private function addressToXML(DOMDocument $document, DOMElement $customer): void { if ($this->getStreet() !== null) { $customer->appendChild( @@ -746,11 +504,7 @@ private function addressToXML(DOMDocument $document, DOMElement $customer) } } - /** - * @param DOMDocument $document - * @param DOMElement $customer - */ - private function preferredLanguageToXML(DOMDocument $document, DOMElement $customer) + private function preferredLanguageToXML(DOMDocument $document, DOMElement $customer): void { if ($this->getPreferredLanguage() !== null) { $customer->appendChild( @@ -762,11 +516,7 @@ private function preferredLanguageToXML(DOMDocument $document, DOMElement $custo } } - /** - * @param DOMDocument $document - * @param DOMElement $customer - */ - private function titleToXML(DOMDocument $document, DOMElement $customer) + private function titleToXML(DOMDocument $document, DOMElement $customer): void { if ($this->getTitle() !== null) { $customer->appendChild( @@ -778,11 +528,7 @@ private function titleToXML(DOMDocument $document, DOMElement $customer) } } - /** - * @param DOMDocument $document - * @param DOMElement $customer - */ - private function postalCodeToXML(DOMDocument $document, DOMElement $customer) + private function postalCodeToXML(DOMDocument $document, DOMElement $customer): void { if ($this->getPostalCode() !== null) { $customer->appendChild( diff --git a/src/Bpack247/CustomerPackStation.php b/src/Bpack247/CustomerPackStation.php index d74e72d3..582d18d8 100644 --- a/src/Bpack247/CustomerPackStation.php +++ b/src/Bpack247/CustomerPackStation.php @@ -1,4 +1,5 @@ customLabel = $customLabel; } - /** - * @return string - */ - public function getCustomLabel() + public function getCustomLabel(): ?string { return $this->customLabel; } - /** - * @param string $orderNumber - */ - public function setOrderNumber($orderNumber) + public function setOrderNumber(?string $orderNumber): void { $this->orderNumber = $orderNumber; } - /** - * @return string - */ - public function getOrderNumber() + public function getOrderNumber(): ?string { return $this->orderNumber; } - /** - * @param string $packstationId - */ - public function setPackstationId($packstationId) + public function setPackstationId(?string $packstationId): void { $this->packstationId = $packstationId; } - /** - * @return string - */ - public function getPackstationId() + public function getPackstationId(): ?string { return $this->packstationId; } - /** - * @param SimpleXMLElement $xml - * - * @return CustomerPackStation - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - $packStation = new CustomerPackStation(); + $packStation = new self(); - if (isset($xml->OrderNumber) && $xml->OrderNumber != '') { - $packStation->setOrderNumber((string) $xml->OrderNumber); + if (isset($xml->OrderNumber) && (string)$xml->OrderNumber !== '') { + $packStation->setOrderNumber((string)$xml->OrderNumber); } - if (isset($xml->CustomLabel) && $xml->CustomLabel != '') { - $packStation->setCustomLabel((string) $xml->CustomLabel); + if (isset($xml->CustomLabel) && (string)$xml->CustomLabel !== '') { + $packStation->setCustomLabel((string)$xml->CustomLabel); } - if (isset($xml->PackstationID) && $xml->PackstationID != '') { - $packStation->setPackstationId((string) $xml->PackstationID); + if (isset($xml->PackstationID) && (string)$xml->PackstationID !== '') { + $packStation->setPackstationId((string)$xml->PackstationID); } return $packStation; diff --git a/src/Bpost.php b/src/Bpost.php index bc378726..76b4805e 100644 --- a/src/Bpost.php +++ b/src/Bpost.php @@ -1,4 +1,5 @@ accountId = (string) $accountId; - $this->passPhrase = (string) $passPhrase; - $this->apiUrl = (string) $apiUrl; - $this->logger = new Logger(); + $this->accountId = $accountId; + $this->passPhrase = $passPhrase; + $this->apiUrl = $apiUrl; + $this->logger = $logger ?? new NullLogger(); } - /** - * @return ApiCaller - */ - public function getApiCaller() + public function getApiCaller(): ApiCaller { if ($this->apiCaller === null) { $this->apiCaller = new ApiCaller($this->logger); @@ -132,441 +74,286 @@ public function getApiCaller() return $this->apiCaller; } - /** - * @param ApiCaller $apiCaller - */ - public function setApiCaller(ApiCaller $apiCaller) + public function setApiCaller(ApiCaller $apiCaller): void { $this->apiCaller = $apiCaller; } /** - * Destructor - */ - public function __destruct() - { - if ($this->curl !== null) { - curl_close($this->curl); - $this->curl = null; - } - } - - /** - * Decode the response - * - * @param SimpleXMLElement $item The item to decode. - * @param array $return Just a placeholder. - * @param int $i A internal counter. - * - * @return array - * * @throws BpostXmlInvalidItemException */ - private static function decodeResponse($item, $return = null, $i = 0) + private static function decodeResponse(SimpleXMLElement $item, ?array $return = null, int $i = 0): array { - if (!$item instanceof SimpleXMLElement) { - throw new BpostXmlInvalidItemException(); - } - - $arrayKeys = array( + $arrayKeys = [ 'barcode', 'orderLine', Insured::INSURANCE_TYPE_ADDITIONAL_INSURANCE, Box\Option\Messaging::MESSAGING_TYPE_INFO_DISTRIBUTED, 'infoPugo', - ); - $integerKeys = array('totalPrice'); + ]; + $integerKeys = ['totalPrice']; - /** @var SimpleXMLElement $value */ foreach ($item as $key => $value) { + $key = (string) $key; $attributes = (array) $value->attributes(); if (!empty($attributes) && isset($attributes['@attributes'])) { $return[$key]['@attributes'] = $attributes['@attributes']; } - // empty if (isset($value['nil']) && (string) $value['nil'] === 'true') { $return[$key] = null; - } // empty - elseif (isset($value[0]) && (string) $value == '') { - if (in_array($key, $arrayKeys)) { + } elseif (isset($value[0]) && (string) $value == '') { + if (in_array($key, $arrayKeys, true)) { $return[$key][] = self::decodeResponse($value); } else { $return[$key] = self::decodeResponse($value, null, 1); } } else { - // arrays - if (in_array($key, $arrayKeys)) { + if (in_array($key, $arrayKeys, true)) { $return[$key][] = (string) $value; - } // booleans - elseif ((string) $value == 'true') { + } elseif ((string) $value === 'true') { $return[$key] = true; - } elseif ((string) $value == 'false') { + } elseif ((string) $value === 'false') { $return[$key] = false; - } // integers - elseif (in_array($key, $integerKeys)) { + } elseif (in_array($key, $integerKeys, true)) { $return[$key] = (int) $value; - } // fallback to string - else { + } else { $return[$key] = (string) $value; } } } - return $return; + return $return ?? []; } /** - * Make the call - * - * @return string|SimpleXMLElement - * * @throws BpostCurlException * @throws BpostInvalidResponseException * @throws BpostInvalidSelectionException * @throws BpostInvalidXmlResponseException */ - private function doCall(HttpRequestBuilderInterface $builder) + private function doCall(HttpRequestBuilderInterface $builder): string|SimpleXMLElement { - $headers = $builder->getHeaders(); - - // build Authorization header + $headers = $builder->getHeaders(); $headers[] = 'Authorization: Basic ' . $this->getAuthorizationHeader(); - // set options - $options = array(); - $options[CURLOPT_URL] = $this->apiUrl . '/' . $this->accountId . $builder->getUrl(); - if ($this->getPort() != 0) { + $options = [ + CURLOPT_URL => rtrim($this->apiUrl, '/') . '/' . rawurlencode($this->accountId) . $builder->getUrl(), + CURLOPT_USERAGENT => $this->getUserAgent(), + CURLOPT_RETURNTRANSFER => true, + CURLOPT_TIMEOUT => $this->getTimeOut(), + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_HTTPHEADER => $headers, + ]; + + if ($this->getPort() !== 0) { $options[CURLOPT_PORT] = $this->getPort(); } - $options[CURLOPT_USERAGENT] = $this->getUserAgent(); - $options[CURLOPT_RETURNTRANSFER] = true; - $options[CURLOPT_TIMEOUT] = (int) $this->getTimeOut(); - $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - $options[CURLOPT_HTTPHEADER] = $headers; - - if ($builder->getMethod() == 'POST') { - $options[CURLOPT_POST] = true; + if ($builder->getMethod() === 'POST') { + $options[CURLOPT_POST] = true; $options[CURLOPT_POSTFIELDS] = $builder->getXml(); } $this->getApiCaller()->doCall($options); - $response = $this->getApiCaller()->getResponseBody(); - $httpCode = $this->getApiCaller()->getResponseHttpCode(); + $response = $this->getApiCaller()->getResponseBody(); + $httpCode = $this->getApiCaller()->getResponseHttpCode(); $contentType = $this->getApiCaller()->getResponseContentType(); - // valid HTTP-code - if (!in_array($httpCode, array(0, 200, 201))) { - // convert into XML + if (!in_array($httpCode, [0, 200, 201], true)) { $xml = @simplexml_load_string($response); - // validate - if ($xml !== false && (substr($xml->getName(), 0, 7) == 'invalid') - ) { - // message + if ($xml !== false && str_starts_with($xml->getName(), 'invalid')) { $message = (string) $xml->error; - $code = isset($xml->code) ? (int) $xml->code : null; - - // throw exception + $code = isset($xml->code) ? (int) $xml->code : null; throw new BpostInvalidSelectionException($message, $code); } $message = ''; - if ( - ($contentType !== null && substr_count($contentType, 'text/plain') > 0) || - in_array($httpCode, array(400, 404)) - ) { + if (($contentType !== null && str_contains($contentType, 'text/plain')) || in_array($httpCode, [400, 404], true)) { $message = $response; } throw new BpostInvalidResponseException($message, $httpCode); } - // if we don't expect XML we can return the content here if (!$builder->isExpectXml()) { return $response; } - // convert into XML $xml = @simplexml_load_string($response); if ($xml === false) { throw new BpostInvalidXmlResponseException(); } - // return the response return $xml; } - /** - * Get the account id - * - * @return string - */ - public function getAccountId() + public function getAccountId(): string { return $this->accountId; } - /** - * Generate the secret string for the Authorization header - * - * @return string - */ - private function getAuthorizationHeader() + private function getAuthorizationHeader(): string { return base64_encode($this->accountId . ':' . $this->passPhrase); } - /** - * Get the passPhrase - * - * @return string - */ - public function getPassPhrase() + public function getPassPhrase(): string { return $this->passPhrase; } - /** - * Get the port - * - * @return int - */ - public function getPort() + public function getPort(): int { - return (int) $this->port; + return $this->port; } - /** - * Get the timeout that will be used - * - * @return int - */ - public function getTimeOut() + public function getTimeOut(): int { - return (int) $this->timeOut; + return $this->timeOut; } - /** - * Get the useragent that will be used. - * Our version will be prepended to yours. - * It will look like: "PHP Bpost/ " - * - * @return string - */ - public function getUserAgent() + public function getUserAgent(): string { - return (string) 'PHP Bpost/' . self::VERSION . ' ' . $this->userAgent; + return 'PHP Bpost/' . self::VERSION . ' ' . ($this->userAgent ?? ''); } - /** - * Set the timeout - * After this time the request will stop. You should handle any errors triggered by this. - * - * @param int $seconds The timeout in seconds. - */ - public function setTimeOut($seconds) + public function setTimeOut(int $seconds): void { - $this->timeOut = (int) $seconds; + $this->timeOut = $seconds; } - /** - * Set the user-agent for you application - * It will be appended to ours, the result will look like: "PHP Bpost/ " - * - * @param string $userAgent Your user-agent, it should look like /. - */ - public function setUserAgent($userAgent) + public function setUserAgent(string $userAgent): void { - $this->userAgent = (string) $userAgent; + $this->userAgent = $userAgent; } - // webservice methods - // orders + // ========== Webservice methods ========== + /** - * Creates a new order. If an order with the same orderReference already exists - * - * @param Order $order - * - * @return bool - * * @throws BpostCurlException * @throws BpostInvalidResponseException * @throws BpostInvalidSelectionException * @throws BpostInvalidXmlResponseException */ - public function createOrReplaceOrder(Order $order) + public function createOrReplaceOrder(Order $order): bool { $builder = new CreateOrReplaceOrderBuilder($order, $this->accountId); - - return $this->doCall($builder) == ''; + return $this->doCall($builder) === ''; } + /** - * Fetch an order - * - * @param string $reference - * - * @return Order - * - * @throws BpostCurlException - * @throws BpostInvalidResponseException - * @throws BpostInvalidSelectionException - * @throws BpostInvalidXmlResponseException * @throws BpostNotImplementedException * @throws BpostXmlNoReferenceFoundException + * @throws BpostInvalidSelectionException + * @throws BpostInvalidValueException + * @throws BpostInvalidResponseException + * @throws BpostCurlException + * @throws BpostInvalidXmlResponseException */ - public function fetchOrder($reference) + public function fetchOrder(string $reference): Order { $builder = new FetchOrderBuilder($reference); - - $xml = $this->doCall($builder); + $xml = $this->doCall($builder); + \assert($xml instanceof SimpleXMLElement); return Order::createFromXML($xml); } /** - * Get the products configuration - * - * @return ProductConfiguration - * * @throws BpostCurlException * @throws BpostInvalidResponseException * @throws BpostInvalidSelectionException * @throws BpostInvalidXmlResponseException */ - public function fetchProductConfig() + public function fetchProductConfig(): ProductConfiguration { $builder = new FetchProductConfigBuilder(); - - $xml = $this->doCall($builder); + $xml = $this->doCall($builder); + \assert($xml instanceof SimpleXMLElement); return ProductConfiguration::createFromXML($xml); } /** - * Modify the status for an order. - * - * @param string $reference The reference for an order - * @param string $status The new status, allowed values are: OPEN, PENDING, CANCELLED, COMPLETED, ON-HOLD or PRINTED - * - * @return bool - * * @throws BpostCurlException * @throws BpostInvalidResponseException * @throws BpostInvalidSelectionException * @throws BpostInvalidValueException * @throws BpostInvalidXmlResponseException */ - public function modifyOrderStatus($reference, $status) + public function modifyOrderStatus(string $reference, string $status): bool { $builder = new ModifyOrderBuilder($reference, $status); - - return $this->doCall($builder) == ''; + return $this->doCall($builder) === ''; } - // labels - - /** - * Get the possible label formats - * - * @return array - */ - public static function getPossibleLabelFormatValues() + /** @return string[] */ + public static function getPossibleLabelFormatValues(): array { - return array( - self::LABEL_FORMAT_A4, - self::LABEL_FORMAT_A6, - ); + return [self::LABEL_FORMAT_A4, self::LABEL_FORMAT_A6]; } /** - * Create the labels for all unprinted boxes in an order. - * The service will return labels for all unprinted boxes for that order. - * Boxes that were unprinted will get the status PRINTED, the boxes that - * had already been printed will remain the same. - * - * @param string $reference The reference for an order - * @param string $format The desired format, allowed values are: A4, A6 - * @param bool $withReturnLabels Should return labels be returned? - * @param bool $asPdf Should we retrieve the PDF-version instead of PNG - * - * @return Bpost\Label[] - * - * @throws BpostCurlException * @throws BpostInvalidResponseException + * @throws BpostLogicException + * @throws BpostCurlException * @throws BpostInvalidSelectionException * @throws BpostInvalidXmlResponseException + * @throws BpostInvalidValueException */ public function createLabelForOrder( - $reference, - $format = self::LABEL_FORMAT_A6, - $withReturnLabels = false, - $asPdf = false - ) { + string $reference, + string $format = self::LABEL_FORMAT_A6, + bool $withReturnLabels = false, + bool $asPdf = false + ): array { $builder = new CreateLabelForOrderBuilder($reference, new LabelFormat($format), $asPdf, $withReturnLabels); - - $xml = $this->doCall($builder); + $xml = $this->doCall($builder); + \assert($xml instanceof SimpleXMLElement); return Labels::createFromXML($xml); } /** - * Create a label for a known barcode. - * - * @param string $barcode The barcode of the parcel - * @param string $format The desired format, allowed values are: A4, A6 - * @param bool $withReturnLabels Should return labels be returned? - * @param bool $asPdf Should we retrieve the PDF-version instead of PNG - * - * @return Bpost\Label[] - * - * @throws BpostCurlException * @throws BpostInvalidResponseException - * @throws BpostInvalidSelectionException + * @throws BpostLogicException + * @throws BpostCurlException * @throws BpostInvalidXmlResponseException + * @throws BpostInvalidSelectionException + * @throws BpostInvalidValueException */ public function createLabelForBox( - $barcode, - $format = self::LABEL_FORMAT_A6, - $withReturnLabels = false, - $asPdf = false - ) { + string $barcode, + string $format = self::LABEL_FORMAT_A6, + bool $withReturnLabels = false, + bool $asPdf = false + ): array { $builder = new CreateLabelForBoxBuilder($barcode, new LabelFormat($format), $asPdf, $withReturnLabels); - - $xml = $this->doCall($builder); + $xml = $this->doCall($builder); + \assert($xml instanceof SimpleXMLElement); return Labels::createFromXML($xml); } /** - * Create labels in bulk, according to the list of order references and the - * list of barcodes. When there is an order reference specified in the - * request, the service will return a label of every box of that order. If - * a certain box was not yet printed, it will have the status PRINTED - * - * @param array $references The references for the order - * @param string $format The desired format, allowed values are: A4, A6 - * @param bool $withReturnLabels Should return labels be returned? - * @param bool $asPdf Should we retrieve the PDF-version instead of PNG - * @param bool $forcePrinting Reprint a already printed label - * - * @return Bpost\Label[] - * - * @throws BpostCurlException * @throws BpostInvalidResponseException - * @throws BpostInvalidSelectionException + * @throws BpostLogicException + * @throws BpostCurlException * @throws BpostInvalidXmlResponseException + * @throws BpostInvalidSelectionException + * @throws BpostInvalidValueException */ public function createLabelInBulkForOrders( array $references, - $format = LabelFormat::FORMAT_A6, - $withReturnLabels = false, - $asPdf = false, - $forcePrinting = false - ) { + string $format = LabelFormat::FORMAT_A6, + bool $withReturnLabels = false, + bool $asPdf = false, + bool $forcePrinting = false + ): array { $builder = new CreateLabelInBulkForOrdersBuilder( $references, new LabelFormat($format), @@ -574,29 +361,19 @@ public function createLabelInBulkForOrders( $withReturnLabels, $forcePrinting ); - $xml = $this->doCall($builder); + \assert($xml instanceof SimpleXMLElement); return Labels::createFromXML($xml); } - /** - * Set a logger to permit to the plugin to log events - * - * @param LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger) + public function setLogger(LoggerInterface $logger): void { $this->logger->setLogger($logger); } - /** - * @param int $weight in grams - * - * @return bool - */ - public function isValidWeight($weight) + public function isValidWeight(int $weight): bool { return self::MIN_WEIGHT <= $weight && $weight <= self::MAX_WEIGHT; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/CreateLabel.php b/src/Bpost/HttpRequestBuilder/CreateLabel.php index 3c709b70..738e488c 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabel.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabel.php @@ -1,70 +1,44 @@ reference = $reference; - $this->labelFormat = $labelFormat; - $this->asPdf = $asPdf; - $this->withReturnLabels = $withReturnLabels; - } + public function __construct( + protected readonly string $reference, + protected readonly LabelFormat $labelFormat, + protected readonly bool $asPdf, + protected readonly bool $withReturnLabels + ) {} /** * @return string */ - abstract protected function getUrlPrefix(); + abstract protected function getUrlPrefix(): string; - /** - * @return null - */ - public function getXml() + public function getXml(): ?string { return null; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Accept: application/vnd.bpost.shm-label-' . ($this->asPdf ? 'pdf' : 'image') . '-v3.3+XML', - 'Content-Type: application/vnd.bpost.shm-labelRequest-v3.3+XML', - ); + $acceptSuffix = $this->asPdf ? 'pdf' : 'image'; + + return [ + 'Accept: application/vnd.bpost.shm-label-' . $acceptSuffix . '-' . ApiVersions::V3_3 . '+XML', + 'Content-Type: application/vnd.bpost.shm-labelRequest-' . ApiVersions::V3_3 . '+XML', + ]; } /** * @return string */ - public function getUrl() + public function getUrl(): string { return sprintf( '/%s/%s/labels/%s%s', @@ -75,19 +49,13 @@ public function getUrl() ); } - /** - * @return string - */ - public function getMethod() + public function getMethod(): string { return self::METHOD_GET; } - /** - * @return bool - */ - public function isExpectXml() + public function isExpectXml(): bool { return true; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php b/src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php index c955376b..42a55870 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php @@ -1,70 +1,41 @@ reference = $reference; - $this->labelFormat = $labelFormat; - $this->asPdf = $asPdf; - $this->withReturnLabels = $withReturnLabels; - } + public function __construct( + protected readonly string $reference, + protected readonly LabelFormat $labelFormat, + protected readonly bool $asPdf, + protected readonly bool $withReturnLabels, + ) {} /** * @return string */ - abstract protected function getUrlPrefix(); + abstract protected function getUrlPrefix(): string; - /** - * @return null - */ - public function getXml() + public function getXml(): ?string { return null; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Accept: application/vnd.bpost.shm-label-' . ($this->asPdf ? 'pdf' : 'image') . '-v3.4+XML', - 'Content-Type: application/vnd.bpost.shm-labelRequest-v3+XML', - ); + $media = $this->asPdf ? 'pdf' : 'image'; + + return [ + 'Accept: application/vnd.bpost.shm-label-' . $media . '-' . ApiVersions::V3_4 . '+XML', + 'Content-Type: application/vnd.bpost.shm-labelRequest-' . ApiVersions::V3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return sprintf( '/%s/%s/labels/%s%s', @@ -75,19 +46,13 @@ public function getUrl() ); } - /** - * @return string - */ - public function getMethod() + public function getMethod(): string { return self::METHOD_GET; } - /** - * @return bool - */ - public function isExpectXml() + public function isExpectXml(): bool { return true; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelForBox.php b/src/Bpost/HttpRequestBuilder/CreateLabelForBox.php index 28bdaa7a..47e80b42 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelForBox.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelForBox.php @@ -1,10 +1,11 @@ references = $references; - $this->labelFormat = $labelFormat; - $this->asPdf = $asPdf; - $this->withReturnLabels = $withReturnLabels; - $this->forcePrinting = $forcePrinting; - } + public function __construct( + private readonly array $references, + private readonly LabelFormat $labelFormat, + private readonly bool $asPdf, + private readonly bool $withReturnLabels, + private readonly bool $forcePrinting + ) {} /** * @return string * * @throws DOMException */ - public function getXml() + public function getXml(): string { $document = new DOMDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace = false; @@ -58,44 +31,46 @@ public function getXml() $batchLabels = $document->createElement('batchLabels'); $batchLabels->setAttribute('xmlns', 'http://schema.post.be/shm/deepintegration/v3/'); + foreach ($this->references as $reference) { - $batchLabels->appendChild( - $document->createElement('order', $reference) - ); + $batchLabels->appendChild($document->createElement('order', (string) $reference)); } + $document->appendChild($batchLabels); - return $document->saveXML(); + return $document->saveXML() ?: ''; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Accept: application/vnd.bpost.shm-label-' . ($this->asPdf ? 'pdf' : 'image') . '-v3+XML', - 'Content-Type: application/vnd.bpost.shm-labelRequest-v3+XML', - ); + $media = $this->asPdf ? 'pdf' : 'image'; + + return [ + 'Accept: application/vnd.bpost.shm-label-' . $media . '-' . ApiVersions::V3 . '+XML', + 'Content-Type: application/vnd.bpost.shm-labelRequest-' . ApiVersions::V3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + + public function getUrl(): string { - return '/labels/' . $this->labelFormat->getValue() - . ($this->withReturnLabels ? '/withReturnLabels' : '') - . ($this->forcePrinting ? '?forcePrinting=true' : ''); + $url = '/labels/' . $this->labelFormat->getValue(); + if ($this->withReturnLabels) { + $url .= '/withReturnLabels'; + } + if ($this->forcePrinting) { + $url .= '?forcePrinting=true'; + } + return $url; } - public function isExpectXml() + public function isExpectXml(): bool { return true; } - public function getMethod() + public function getMethod(): string { return self::METHOD_POST; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php b/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php index ee5444a5..ac0c0221 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php @@ -1,56 +1,24 @@ references = $references; - $this->labelFormat = $labelFormat; - $this->asPdf = $asPdf; - $this->withReturnLabels = $withReturnLabels; - $this->forcePrinting = $forcePrinting; - } - - /** - * @return string - * - * @throws DOMException - */ - public function getXml() + public function getXml(): string { $document = new DOMDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace = false; @@ -58,44 +26,47 @@ public function getXml() $batchLabels = $document->createElement('batchLabels'); $batchLabels->setAttribute('xmlns', 'http://schema.post.be/shm/deepintegration/v3/'); + foreach ($this->references as $reference) { - $batchLabels->appendChild( - $document->createElement('order', $reference) - ); + $batchLabels->appendChild($document->createElement('order', (string) $reference)); } + $document->appendChild($batchLabels); - return $document->saveXML(); + return $document->saveXML() ?: ''; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Accept: application/vnd.bpost.shm-label-' . ($this->asPdf ? 'pdf' : 'image') . '-v3.4+XML', - 'Content-Type: application/vnd.bpost.shm-labelRequest-v3+XML', - ); + $media = $this->asPdf ? 'pdf' : 'image'; + + return [ + 'Accept: application/vnd.bpost.shm-label-' . $media . '-' . ApiVersions::V3_4 . '+XML', + 'Content-Type: application/vnd.bpost.shm-labelRequest-' . ApiVersions::V3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { - return '/labels/' . $this->labelFormat->getValue() - . ($this->withReturnLabels ? '/withReturnLabels' : '') - . ($this->forcePrinting ? '?forcePrinting=true' : ''); + $url = '/labels/' . $this->labelFormat->getValue(); + + if ($this->withReturnLabels) { + $url .= '/withReturnLabels'; + } + if ($this->forcePrinting) { + $url .= '?forcePrinting=true'; + } + + return $url; } - public function isExpectXml() + public function isExpectXml(): bool { return true; } - public function getMethod() + public function getMethod(): string { return self::METHOD_POST; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php b/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php index c8d30973..d08c148f 100644 --- a/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php +++ b/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php @@ -1,75 +1,52 @@ order = $order; - $this->accountId = $accountId; - } - /** - * @return string - */ - public function getXml() + public function getXml(): string { - $document = new DOMDocument('1.0', 'utf-8'); + $document = new DOMDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $document->appendChild( - $this->order->toXML( - $document, - $this->accountId - ) + $this->order->toXML($document, $this->accountId) ); - return $document->saveXML(); + return $document->saveXML() ?: ''; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Content-type: application/vnd.bpost.shm-order-v3.3+XML', - ); + return [ + 'Content-Type: application/vnd.bpost.shm-order-' . ApiVersions::V3_3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/orders'; } - public function isExpectXml() + public function isExpectXml(): bool { return false; } - public function getMethod() + public function getMethod(): string { return self::METHOD_POST; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php b/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php index 17c42eeb..a10fbf5a 100644 --- a/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php @@ -1,74 +1,50 @@ order = $order; - $this->accountId = $accountId; - } - - /** - * @return string - */ - public function getXml() - { - $document = new DOMDocument('1.0', 'utf-8'); + $document = new DOMDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $document->appendChild( - $this->order->toXML( - $document, - $this->accountId - ) + $this->order->toXML($document, $this->accountId) ); - return $document->saveXML(); + return $document->saveXML() ?: ''; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Content-type: application/vnd.bpost.shm-order-v5+XML', - ); + return [ + 'Content-Type: application/vnd.bpost.shm-order-' . ApiVersions::V5 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/orders'; } - public function isExpectXml() + public function isExpectXml(): bool { return false; } - public function getMethod() + public function getMethod(): string { return self::METHOD_POST; } diff --git a/src/Bpost/HttpRequestBuilder/FetchOrder.php b/src/Bpost/HttpRequestBuilder/FetchOrder.php index 78f08629..c1e3add3 100644 --- a/src/Bpost/HttpRequestBuilder/FetchOrder.php +++ b/src/Bpost/HttpRequestBuilder/FetchOrder.php @@ -1,55 +1,40 @@ reference = (string) $reference; - } + public function __construct( + private readonly string $reference + ) {} - /** - * @return string|null - */ - public function getXml() + public function getXml(): ?string { return null; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Accept: application/vnd.bpost.shm-order-v3.3+XML', - ); + return [ + 'Accept: application/vnd.bpost.shm-order-' . ApiVersions::V3_3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/orders/' . $this->reference; } - public function isExpectXml() + public function isExpectXml(): bool { return true; } - public function getMethod() + public function getMethod(): string { return self::METHOD_GET; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php b/src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php index e9b79609..4d9b367f 100644 --- a/src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php @@ -1,55 +1,40 @@ reference = (string) $reference; - } + public function __construct( + private readonly string $reference + ) {} - /** - * @return string|null - */ - public function getXml() + public function getXml(): ?string { return null; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Accept: application/vnd.bpost.shm-order-v3.5+XML', - ); + return [ + 'Accept: application/vnd.bpost.shm-order-' . ApiVersions::V3_5 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/orders/' . $this->reference; } - public function isExpectXml() + public function isExpectXml(): bool { return true; } - public function getMethod() + public function getMethod(): string { return self::METHOD_GET; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/FetchProductConfig.php b/src/Bpost/HttpRequestBuilder/FetchProductConfig.php index cbab4155..cdec4784 100644 --- a/src/Bpost/HttpRequestBuilder/FetchProductConfig.php +++ b/src/Bpost/HttpRequestBuilder/FetchProductConfig.php @@ -1,41 +1,36 @@ reference = (string) $reference; - $this->status = strtoupper($status); - if (!in_array($this->status, Box::getPossibleStatusValues())) { - throw new BpostInvalidValueException('status', $this->status, Box::getPossibleStatusValues()); + public function __construct( + private readonly string $reference, + string $status + ) { + $normalized = strtoupper($status); + if (!in_array($normalized, Box::getPossibleStatusValues(), true)) { + throw new BpostInvalidValueException('status', $normalized, Box::getPossibleStatusValues()); } + $this->status = $normalized; } + private string $status; - /** - * @return string|null - */ - public function getXml() + public function getXml(): string { - $document = new DOMDocument('1.0', 'utf-8'); + $document = new DOMDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $orderUpdate = $document->createElement('orderUpdate'); $orderUpdate->setAttribute('xmlns', 'http://schema.post.be/shm/deepintegration/v3/'); $orderUpdate->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $orderUpdate->appendChild( - $document->createElement('status', $this->status) - ); + $orderUpdate->appendChild($document->createElement('status', $this->status)); + $document->appendChild($orderUpdate); - return $document->saveXML(); + return $document->saveXML() ?: ''; } - /** - * @return string[] - */ - public function getHeaders() + + public function getHeaders(): array { - return array( - 'Content-type: application/vnd.bpost.shm-orderUpdate-v3+XML', - ); + return [ + 'Content-Type: application/vnd.bpost.shm-orderUpdate-' . ApiVersions::V3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/orders/' . $this->reference; } - public function isExpectXml() + public function isExpectXml(): bool { return false; } - public function getMethod() + public function getMethod(): string { return self::METHOD_POST; } -} +} \ No newline at end of file diff --git a/src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php b/src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php index f9ccea7a..75b0c0af 100644 --- a/src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php @@ -1,79 +1,65 @@ reference = (string) $reference; - $this->status = strtoupper($status); - if (!in_array($this->status, Box::getPossibleStatusValues())) { - throw new BpostInvalidValueException('status', $this->status, Box::getPossibleStatusValues()); + public function __construct( + private readonly string $reference, + string $status + ) { + $normalized = strtoupper($status); + if (!in_array($normalized, Box::getPossibleStatusValues(), true)) { + throw new BpostInvalidValueException('status', $normalized, Box::getPossibleStatusValues()); } + $this->status = $normalized; } - /** - * @return string|null - */ - public function getXml() + private string $status; + + public function getXml(): string { - $document = new DOMDocument('1.0', 'utf-8'); + $document = new DOMDocument('1.0', 'UTF-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $orderUpdate = $document->createElement('orderUpdate'); $orderUpdate->setAttribute('xmlns', 'http://schema.post.be/shm/deepintegration/v3/'); $orderUpdate->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $orderUpdate->appendChild( - $document->createElement('status', $this->status) - ); + $orderUpdate->appendChild($document->createElement('status', $this->status)); + $document->appendChild($orderUpdate); - return $document->saveXML(); + return $document->saveXML() ?: ''; } - /** - * @return string[] - */ - public function getHeaders() + public function getHeaders(): array { - return array( - 'Content-type: application/vnd.bpost.shm-orderUpdate-v3+XML', - ); + return [ + 'Content-Type: application/vnd.bpost.shm-orderUpdate-' . ApiVersions::V3 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/orders/' . $this->reference; } - public function isExpectXml() + public function isExpectXml(): bool { return false; } - public function getMethod() + public function getMethod(): string { return self::METHOD_POST; } diff --git a/src/Bpost/Label.php b/src/Bpost/Label.php index aadfaa41..1dc39d68 100644 --- a/src/Bpost/Label.php +++ b/src/Bpost/Label.php @@ -1,4 +1,5 @@ barcodes[] = $barcode; } - /** - * @return string - */ - public function getBarcode() + public function setBarcodes(array $barcodes): void { - if (is_array($this->getBarcodes())) { - $barcode = current($this->getBarcodes()); - - return $barcode->getBarcode(); - } - - return ''; + $this->barcodes = $barcodes; } - /** - * @param Barcode[] $barcodes - */ - public function setBarcodes(array $barcodes) + /** @return Barcode[] */ + public function getBarcodes(): array { - $this->barcodes = $barcodes; + return $this->barcodes; } - /** - * @return Barcode[] - */ - public function getBarcodes() + public function getBarcode(): string { - return $this->barcodes; + if (!empty($this->barcodes)) { + $first = $this->barcodes[0]; + return $first->getBarcode() ?? ''; + } + + return ''; } - /** - * @param string $bytes - */ - public function setBytes($bytes) + public function setBytes(string $bytes): void { $this->bytes = $bytes; } - /** - * @return string - */ - public function getBytes() + public function getBytes(): string { return $this->bytes; } /** - * @param string $mimeType - * * @throws BpostInvalidValueException */ - public function setMimeType($mimeType) + public function setMimeType(string $mimeType): void { - if (!in_array($mimeType, self::getPossibleMimeTypeValues())) { + if (!in_array($mimeType, self::getPossibleMimeTypeValues(), true)) { throw new BpostInvalidValueException('mimeType', $mimeType, self::getPossibleMimeTypeValues()); } $this->mimeType = $mimeType; } - /** - * @return string - */ - public function getMimeType() + public function getMimeType(): ?string { return $this->mimeType; } - /** - * @return array - */ - public static function getPossibleMimeTypeValues() + /** @return string[] */ + public static function getPossibleMimeTypeValues(): array { - return array( + return [ self::LABEL_MIME_TYPE_IMAGE_PNG, self::LABEL_MIME_TYPE_IMAGE_PDF, self::LABEL_MIME_TYPE_APPLICATION_PDF, - ); + ]; } + /** * Output the bytes directly to the screen */ @@ -131,27 +97,26 @@ public function output() } /** - * @param SimpleXMLElement $xml - * - * @return Label - * * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - $label = new Label(); + $label = new self(); + if (isset($xml->barcodeWithReference)) { foreach ($xml->barcodeWithReference as $barcodeWithReference) { $label->addBarcode(Barcode::createFromXML($barcodeWithReference)); } } - if (isset($xml->mimeType) && $xml->mimeType != '') { + + if (!empty($xml->mimeType)) { $label->setMimeType((string) $xml->mimeType); } - if (isset($xml->bytes) && $xml->bytes != '') { - $label->setBytes((string) base64_decode($xml->bytes)); + + if (!empty($xml->bytes)) { + $label->setBytes((string) base64_decode((string) $xml->bytes)); } return $label; } -} +} \ No newline at end of file diff --git a/src/Bpost/Label/Barcode.php b/src/Bpost/Label/Barcode.php index ba15df6e..15a3534c 100644 --- a/src/Bpost/Label/Barcode.php +++ b/src/Bpost/Label/Barcode.php @@ -1,4 +1,5 @@ barcode = (string) $barcode; + $this->barcode = $barcode; } - /** - * @return string - */ - public function getBarcode() + public function getBarcode(): ?string { return $this->barcode; } - /** - * @param string $reference - */ - public function setReference($reference) + public function setReference(?string $reference): void { $this->reference = $reference; } - /** - * @return string - */ - public function getReference() + public function getReference(): ?string { return $this->reference; } - /** - * @param SimpleXMLElement $xml - * - * @return self - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { $self = new self(); - if (isset($xml->barcode) && $xml->barcode != '') { - $self->setBarcode((string) $xml->barcode); + + if (isset($xml->barcode) && (string)$xml->barcode !== '') { + $self->setBarcode((string)$xml->barcode); } - if (isset($xml->reference) && $xml->reference != '') { - $self->setReference((string) $xml->reference); + if (isset($xml->reference) && (string)$xml->reference !== '') { + $self->setReference((string)$xml->reference); } return $self; } } + diff --git a/src/Bpost/Labels.php b/src/Bpost/Labels.php index e5e9a3f5..a75abdea 100644 --- a/src/Bpost/Labels.php +++ b/src/Bpost/Labels.php @@ -1,7 +1,9 @@ label)) { - foreach ($xml->label as $label) { - $labels[] = Label::createFromXML($label); + foreach ($xml->label as $labelXml) { + $labels[] = Label::createFromXML($labelXml); } } return $labels; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order.php b/src/Bpost/Order.php index 6c7d19ad..4f6e750c 100644 --- a/src/Bpost/Order.php +++ b/src/Bpost/Order.php @@ -1,9 +1,11 @@ setReference($reference); } - /** - * @param Box[] $boxes - */ - public function setBoxes(array $boxes) + public function setBoxes(array $boxes): void { $this->boxes = $boxes; } - /** - * @return Box[] - */ - public function getBoxes() + public function getBoxes(): array { return $this->boxes; } - /** - * Add a box - * - * @param Box $box - */ - public function addBox(Box $box) + public function addBox(Box $box): void { $this->boxes[] = $box; } - /** - * @param string $costCenter - */ - public function setCostCenter($costCenter) + public function setCostCenter(?string $costCenter): void { $this->costCenter = $costCenter; } - /** - * @return string - */ - public function getCostCenter() + public function getCostCenter(): ?string { return $this->costCenter; } - /** - * @param Line[] $lines - */ - public function setLines(array $lines) + public function setLines(array $lines): void { $this->lines = $lines; } - /** - * @return Line[] - */ - public function getLines() + public function getLines(): array { return $this->lines; } - /** - * Add an order line - * - * @param Line $line - */ - public function addLine(Line $line) + public function addLine(Line $line): void { $this->lines[] = $line; } - /** - * @param string $reference - */ - public function setReference($reference) + public function setReference(string $reference): void { $this->reference = $reference; } - /** - * @return string - */ - public function getReference() + public function getReference(): string { return $this->reference; } /** - * Return the object as an array for usage in the XML - * - * @param DOMDocument $document - * @param string $accountId - * - * @return DOMElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $accountId) + public function toXML(DOMDocument $document, string $accountId): DOMElement { - $order = $document->createElement( - 'tns:order' - ); - $order->setAttribute( - 'xmlns:common', - 'http://schema.post.be/shm/deepintegration/v5/common' - ); - $order->setAttribute( - 'xmlns:tns', - 'http://schema.post.be/shm/deepintegration/v5/' - ); - $order->setAttribute( - 'xmlns', - 'http://schema.post.be/shm/deepintegration/v5/national' - ); - $order->setAttribute( - 'xmlns:international', - 'http://schema.post.be/shm/deepintegration/v5/international' - ); - $order->setAttribute( - 'xmlns:xsi', - 'http://www.w3.org/2001/XMLSchema-instance' - ); - $order->setAttribute( - 'xsi:schemaLocation', - 'http://schema.post.be/shm/deepintegration/v5/' - ); + $order = $document->createElement('tns:order'); + $order->setAttribute('xmlns:common', 'http://schema.post.be/shm/deepintegration/v5/common'); + $order->setAttribute('xmlns:tns', 'http://schema.post.be/shm/deepintegration/v5/'); + $order->setAttribute('xmlns', 'http://schema.post.be/shm/deepintegration/v5/national'); + $order->setAttribute('xmlns:international', 'http://schema.post.be/shm/deepintegration/v5/international'); + $order->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + $order->setAttribute('xsi:schemaLocation', 'http://schema.post.be/shm/deepintegration/v5/'); + $order->setAttribute('xmlns:national', 'http://schema.post.be/shm/deepintegration/v5/national'); $document->appendChild($order); - $order->appendChild( - $document->createElement( - 'tns:accountId', - (string) $accountId - ) - ); + $order->appendChild($document->createElement('tns:accountId', $accountId)); + $order->appendChild($document->createElement('tns:reference', $this->getReference())); - if ($this->getReference() !== null) { - $order->appendChild( - $document->createElement( - 'tns:reference', - $this->getReference() - ) - ); - } if ($this->getCostCenter() !== null) { - $order->appendChild( - $document->createElement( - 'tns:costCenter', - $this->getCostCenter() - ) - ); + $order->appendChild($document->createElement('tns:costCenter', $this->getCostCenter())); } - $lines = $this->getLines(); - if (!empty($lines)) { - foreach ($lines as $line) { - /** @var $line \Bpost\BpostApiClient\Bpost\Order\Line */ - $order->appendChild( - $line->toXML($document, 'tns') - ); - } + foreach ($this->getLines() as $line) { + $order->appendChild($line->toXML($document, 'tns')); } - $boxes = $this->getBoxes(); - if (!empty($boxes)) { - foreach ($boxes as $box) { - /** @var $box \Bpost\BpostApiClient\Bpost\Order\Box */ - $order->appendChild( - $box->toXML($document, 'tns') - ); - } + foreach ($this->getBoxes() as $box) { + $order->appendChild($box->toXML($document, 'tns')); } return $order; } /** - * @param SimpleXMLElement $xml - * - * @return Order - * * @throws BpostXmlNoReferenceFoundException * @throws BpostNotImplementedException + * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): Order { - // @todo work with classmaps ... if (!isset($xml->reference)) { throw new BpostXmlNoReferenceFoundException(); } $order = new Order((string) $xml->reference); - if (isset($xml->costCenter) && $xml->costCenter != '') { + if (isset($xml->costCenter) && (string) $xml->costCenter !== '') { $order->setCostCenter((string) $xml->costCenter); } + if (isset($xml->orderLine)) { foreach ($xml->orderLine as $orderLine) { - $order->addLine( - Line::createFromXML($orderLine) - ); + $order->addLine(Line::createFromXML($orderLine)); } } + if (isset($xml->box)) { foreach ($xml->box as $box) { $order->addBox(Box::createFromXML($box)); diff --git a/src/Bpost/Order/Address.php b/src/Bpost/Order/Address.php index 028c4afa..1e9cb928 100644 --- a/src/Bpost/Order/Address.php +++ b/src/Bpost/Order/Address.php @@ -1,4 +1,5 @@ setStreetName($streetName); + if ($number !== null) $this->setNumber($number); + if ($box !== null) $this->setBox($box); + if ($postalCode !== null) $this->setPostalCode($postalCode); + if ($locality !== null) $this->setLocality($locality); + if ($countryCode !== null) $this->setCountryCode($countryCode); + } /** - * @param string $box - * * @throws BpostInvalidLengthException */ - public function setBox($box) + public function setBox(?string $box): void { - $length = 8; - if (mb_strlen($box) > $length) { - throw new BpostInvalidLengthException('box', mb_strlen($box), $length); + if ($box === null) { + $this->box = null; + return; + } + + $max = 8; + if (mb_strlen($box) > $max) { + throw new BpostInvalidLengthException('box', mb_strlen($box), $max); } $this->box = $box; } - - /** - * @return string - */ - public function getBox() + public function getBox(): ?string { return $this->box; } /** - * @param string $countryCode - * * @throws BpostInvalidLengthException */ - public function setCountryCode($countryCode) + public function setCountryCode(string $countryCode): void { - $length = 2; - if (mb_strlen($countryCode) > $length) { - throw new BpostInvalidLengthException('countryCode', mb_strlen($countryCode), $length); + $max = 2; + if (mb_strlen($countryCode) > $max) { + throw new BpostInvalidLengthException('countryCode', mb_strlen($countryCode), $max); } $this->countryCode = strtoupper($countryCode); } - - /** - * @return string - */ - public function getCountryCode() + public function getCountryCode(): ?string { return $this->countryCode; } /** - * @param string $locality - * * @throws BpostInvalidLengthException */ - public function setLocality($locality) + public function setLocality(string $locality): void { - $length = 40; - if (mb_strlen($locality) > $length) { - throw new BpostInvalidLengthException('locality', mb_strlen($locality), $length); + $max = 40; + if (mb_strlen($locality) > $max) { + throw new BpostInvalidLengthException('locality', mb_strlen($locality), $max); } $this->locality = $locality; } - - /** - * @return string - */ - public function getLocality() + public function getLocality(): ?string { return $this->locality; } /** - * @param string $number - * * @throws BpostInvalidLengthException */ - public function setNumber($number) + public function setNumber(string $number): void { - $length = 8; - if (mb_strlen($number) > $length) { - throw new BpostInvalidLengthException('number', mb_strlen($number), $length); + $max = 8; + if (mb_strlen($number) > $max) { + throw new BpostInvalidLengthException('number', mb_strlen($number), $max); } $this->number = $number; } - - /** - * @return string - */ - public function getNumber() + public function getNumber(): ?string { return $this->number; } /** - * @param string $postalCode - * * @throws BpostInvalidLengthException */ - public function setPostalCode($postalCode) + public function setPostalCode(string $postalCode): void { - $length = 40; - if (mb_strlen($postalCode) > $length) { - throw new BpostInvalidLengthException('postalCode', mb_strlen($postalCode), $length); + $max = 40; + if (mb_strlen($postalCode) > $max) { + throw new BpostInvalidLengthException('postalCode', mb_strlen($postalCode), $max); } $this->postalCode = $postalCode; } - - /** - * @return string - */ - public function getPostalCode() + public function getPostalCode(): ?string { return $this->postalCode; } /** - * @param string $streetName - * * @throws BpostInvalidLengthException */ - public function setStreetName($streetName) + public function setStreetName(string $streetName): void { - $length = 40; - if (mb_strlen($streetName) > $length) { - throw new BpostInvalidLengthException('streetName', mb_strlen($streetName), $length); + $max = 40; + if (mb_strlen($streetName) > $max) { + throw new BpostInvalidLengthException('streetName', mb_strlen($streetName), $max); } $this->streetName = $streetName; } - - /** - * @return string - */ - public function getStreetName() + public function getStreetName(): ?string { return $this->streetName; } /** - * @param string $streetName - * @param string $number - * @param string $box - * @param string $postalCode - * @param string $locality - * @param string $countryCode - * - * @throws BpostInvalidLengthException + * @throws \DOMException */ - public function __construct( - $streetName = null, - $number = null, - $box = null, - $postalCode = null, - $locality = null, - $countryCode = null - ) { - if ($streetName !== null) { - $this->setStreetName($streetName); + public function toXML(DOMDocument $document, ?string $prefix = 'common'): DOMElement + { + // + $address = $document->createElement( + XmlHelper::getPrefixedTagName(self::TAG_NAME, $prefix) + ); + + // , , + if ($this->streetName !== null) { + $address->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('streetName', $prefix), + $this->streetName + )); } - if ($number !== null) { - $this->setNumber($number); + if ($this->number !== null) { + $address->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('number', $prefix), + $this->number + )); } - if ($box !== null) { - $this->setBox($box); + if ($this->box !== null) { + $address->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('box', $prefix), + $this->box + )); } - if ($postalCode !== null) { - $this->setPostalCode($postalCode); + + // , , + if ($this->postalCode !== null) { + $address->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('postalCode', $prefix), + $this->postalCode + )); } - if ($locality !== null) { - $this->setLocality($locality); + if ($this->locality !== null) { + $address->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('locality', $prefix), + $this->locality + )); } - if ($countryCode !== null) { - $this->setCountryCode($countryCode); + if ($this->countryCode !== null) { + $address->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('countryCode', $prefix), + $this->countryCode + )); } - } - - /** - * Return the object as an array for usage in the XML - * - * @param DOMDocument $document - * @param string $prefix - * - * @return DOMElement - */ - public function toXML(DOMDocument $document, $prefix = 'common') - { - $tagName = static::TAG_NAME; - $address = $document->createElement($tagName); - $document->appendChild($address); - - $this->streetToXML($document, $prefix, $address); - $this->streetNumbersToXML($document, $prefix, $address); - $this->localityToXML($document, $prefix, $address); - $this->countryToXML($document, $prefix, $address); return $address; } /** - * @param SimpleXMLElement $xml - * - * @return Address - * * @throws BpostInvalidLengthException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): Address { - $address = new Address(); - + $address = new static(); if (isset($xml->streetName) && $xml->streetName != '') { $address->setStreetName((string) $xml->streetName); } @@ -268,91 +222,64 @@ public static function createFromXML(SimpleXMLElement $xml) if (isset($xml->countryCode) && $xml->countryCode != '') { $address->setCountryCode((string) $xml->countryCode); } - return $address; } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $address + * @throws \DOMException */ - private function streetToXML(DOMDocument $document, $prefix, DOMElement $address) + private function streetToXML(DOMDocument $document, string $prefix, DOMElement $address): void { - if ($this->getStreetName() !== null) { + if ($this->streetName !== null) { $address->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('streetName', $prefix), - $this->getStreetName() - ) + $document->createElement(XmlHelper::getPrefixedTagName('streetName', $prefix), $this->streetName) ); } } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $address + * @throws \DOMException */ - private function localityToXML(DOMDocument $document, $prefix, DOMElement $address) + private function localityToXML(DOMDocument $document, string $prefix, DOMElement $address): void { - if ($this->getPostalCode() !== null) { + if ($this->postalCode !== null) { $address->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('postalCode', $prefix), - $this->getPostalCode() - ) + $document->createElement(XmlHelper::getPrefixedTagName('postalCode', $prefix), $this->postalCode) ); } - if ($this->getLocality() !== null) { + if ($this->locality !== null) { $address->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('locality', $prefix), - $this->getLocality() - ) + $document->createElement(XmlHelper::getPrefixedTagName('locality', $prefix), $this->locality) ); } } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $address + * @throws \DOMException */ - private function countryToXML(DOMDocument $document, $prefix, DOMElement $address) + private function countryToXML(DOMDocument $document, string $prefix, DOMElement $address): void { - if ($this->getCountryCode() !== null) { + if ($this->countryCode !== null) { $address->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('countryCode', $prefix), - $this->getCountryCode() - ) + $document->createElement(XmlHelper::getPrefixedTagName('countryCode', $prefix), $this->countryCode) ); } } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $address + * @throws \DOMException */ - private function streetNumbersToXML(DOMDocument $document, $prefix, DOMElement $address) + private function streetNumbersToXML(DOMDocument $document, string $prefix, DOMElement $address): void { - if ($this->getNumber() !== null) { + if ($this->number !== null) { $address->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('number', $prefix), - $this->getNumber() - ) + $document->createElement(XmlHelper::getPrefixedTagName('number', $prefix), $this->number) ); } - if ($this->getBox() !== null) { + if ($this->box !== null) { $address->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('box', $prefix), - $this->getBox() - ) + $document->createElement(XmlHelper::getPrefixedTagName('box', $prefix), $this->box) ); } } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box.php b/src/Bpost/Order/Box.php index 90128530..765751dc 100644 --- a/src/Bpost/Order/Box.php +++ b/src/Bpost/Order/Box.php @@ -1,7 +1,10 @@ internationalBox = $internationalBox; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\Box\International - */ - public function getInternationalBox() + public function getInternationalBox(): ?International { return $this->internationalBox; } - /** - * @param \Bpost\BpostApiClient\Bpost\Order\Box\National $nationalBox - */ - public function setNationalBox(Box\National $nationalBox) + public function setNationalBox(National $nationalBox): void { $this->nationalBox = $nationalBox; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\Box\National - */ - public function getNationalBox() + public function getNationalBox(): ?National { return $this->nationalBox; } - /** - * @param string $remark - */ - public function setRemark($remark) + public function setRemark(string $remark): void { $this->remark = $remark; } - /** - * @return string - */ - public function getRemark() + public function getRemark(): ?string { return $this->remark; } - /** - * @param \Bpost\BpostApiClient\Bpost\Order\Sender $sender - */ - public function setSender(Sender $sender) + public function setSender(Sender $sender): void { $this->sender = $sender; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\Sender - */ - public function getSender() + public function getSender(): ?Sender { return $this->sender; } /** - * @param string $status - * * @throws BpostInvalidValueException */ - public function setStatus($status) + public function setStatus(string $status): void { $status = strtoupper($status); - if (!in_array($status, self::getPossibleStatusValues())) { + if (!in_array($status, self::getPossibleStatusValues(), true)) { throw new BpostInvalidValueException('status', $status, self::getPossibleStatusValues()); } - $this->status = $status; } - /** - * @param string $barcode - */ - public function setBarcode($barcode) + public function setBarcode(string $barcode): void { - $this->barcode = strtoupper((string) $barcode); + $this->barcode = strtoupper($barcode); } - /** - * @return string - */ - public function getBarcode() + public function getBarcode(): ?string { return $this->barcode; } - /** - * @return string - */ - public function getStatus() + public function getStatus(): ?string { return $this->status; } - /** - * @param string $additionalCustomerReference - */ - public function setAdditionalCustomerReference($additionalCustomerReference) + public function setAdditionalCustomerReference(string $additionalCustomerReference): void { - $this->additionalCustomerReference = (string) $additionalCustomerReference; + $this->additionalCustomerReference = $additionalCustomerReference; } - /** - * @return string - */ - public function getAdditionalCustomerReference() + public function getAdditionalCustomerReference(): ?string { return $this->additionalCustomerReference; } - /** - * @return array - */ - public static function getPossibleStatusValues() + + public static function getPossibleStatusValues(): array { - return array( + return [ self::BOX_STATUS_OPEN, self::BOX_STATUS_PENDING, self::BOX_STATUS_PRINTED, @@ -193,18 +130,13 @@ public static function getPossibleStatusValues() self::BOX_STATUS_AWAITING_PICKUP, self::BOX_STATUS_DELIVERED, self::BOX_STATUS_BACK_TO_SENDER, - ); + ]; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement { $box = $document->createElement(XmlHelper::getPrefixedTagName('box', $prefix)); @@ -218,160 +150,118 @@ public function toXML(DOMDocument $document, $prefix = null) } /** - * @param SimpleXMLElement $xml - * - * @return Box - * * @throws BpostInvalidValueException * @throws BpostNotImplementedException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - $box = new Box(); + $box = new self(); + if (isset($xml->sender)) { $box->setSender( Sender::createFromXML( - $xml->sender->children( - 'http://schema.post.be/shm/deepintegration/v3/common' - ) + $xml->sender->children('http://schema.post.be/shm/deepintegration/v3/common') ) ); } + if (isset($xml->nationalBox)) { - /** @var SimpleXMLElement $nationalBoxData */ $nationalBoxData = $xml->nationalBox->children('http://schema.post.be/shm/deepintegration/v3/national'); - $classNameExtracted = $nationalBoxData->getName(); - if ($classNameExtracted == 'at24-7') { + if ($classNameExtracted === 'at24-7') { $classNameExtracted = 'at247'; } - - // build classname based on the tag name - $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\' . ucfirst($classNameExtracted); - + $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\' . ucfirst((string)$classNameExtracted); XmlHelper::assertMethodCreateFromXmlExists($className); - $nationalBox = call_user_func(array($className, 'createFromXML'), $nationalBoxData); - + /** @var National $nationalBox */ + $nationalBox = call_user_func([$className, 'createFromXML'], $nationalBoxData); $box->setNationalBox($nationalBox); } + if (isset($xml->internationalBox)) { - /** @var SimpleXMLElement $internationalBoxData */ $internationalBoxData = $xml->internationalBox->children('http://schema.post.be/shm/deepintegration/v3/international'); - $classNameExtracted = $internationalBoxData->getName(); - if ($classNameExtracted == 'atIntlHome') { + if ($classNameExtracted === 'atIntlHome') { $classNameExtracted = 'international'; } - // build classname based on the tag name - $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\' . ucfirst($classNameExtracted); - + $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\' . ucfirst((string)$classNameExtracted); XmlHelper::assertMethodCreateFromXmlExists($className); - $internationalBox = call_user_func( - array($className, 'createFromXML'), - $internationalBoxData - ); - + /** @var International $internationalBox */ + $internationalBox = call_user_func([$className, 'createFromXML'], $internationalBoxData); $box->setInternationalBox($internationalBox); } - if (isset($xml->remark) && $xml->remark != '') { - $box->setRemark((string) $xml->remark); + + if (isset($xml->remark) && (string) $xml->remark !== '') { + $box->setRemark((string)$xml->remark); } - if (isset($xml->additionalCustomerReference) && $xml->additionalCustomerReference != '') { - $box->setAdditionalCustomerReference((string) $xml->additionalCustomerReference); + if (isset($xml->additionalCustomerReference) && (string) $xml->additionalCustomerReference !== '') { + $box->setAdditionalCustomerReference((string)$xml->additionalCustomerReference); } if (!empty($xml->barcode)) { - $box->setBarcode((string) $xml->barcode); + $box->setBarcode((string)$xml->barcode); } - if (isset($xml->status) && $xml->status != '') { - $box->setStatus((string) $xml->status); + if (isset($xml->status) && (string) $xml->status !== '') { + $box->setStatus((string)$xml->status); } return $box; } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $box + * @throws \DOMException */ - private function barcodeToXML(DOMDocument $document, $prefix, DOMElement $box) + private function barcodeToXML(DOMDocument $document, ?string $prefix, DOMElement $box): void { - if ($this->getBarcode() !== null) { + if ($this->barcode !== null) { $box->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('barcode', $prefix), - $this->getBarcode() - ) + $document->createElement(XmlHelper::getPrefixedTagName('barcode', $prefix), $this->barcode) ); } } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $box + * @throws \DOMException */ - private function boxToXML(DOMDocument $document, $prefix, DOMElement $box) + private function boxToXML(DOMDocument $document, ?string $prefix, DOMElement $box): void { - if ($this->getNationalBox() !== null) { - $box->appendChild( - $this->getNationalBox()->toXML($document, $prefix) - ); + if ($this->nationalBox !== null) { + $box->appendChild($this->nationalBox->toXML($document, $prefix)); } - if ($this->getInternationalBox() !== null) { - $box->appendChild( - $this->getInternationalBox()->toXML($document, $prefix) - ); + if ($this->internationalBox !== null) { + $box->appendChild($this->internationalBox->toXML($document, $prefix)); } } - /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $box - */ - private function senderToXML(DOMDocument $document, $prefix, DOMElement $box) + private function senderToXML(DOMDocument $document, ?string $prefix, DOMElement $box): void { - if ($this->getSender() !== null) { - $box->appendChild( - $this->getSender()->toXML($document, $prefix) - ); + if ($this->sender !== null) { + $box->appendChild($this->sender->toXML($document, $prefix)); } } /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $box + * @throws \DOMException */ - private function remarkToXML(DOMDocument $document, $prefix, DOMElement $box) + private function remarkToXML(DOMDocument $document, ?string $prefix, DOMElement $box): void { - if ($this->getRemark() !== null) { + if ($this->remark !== null) { $box->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('remark', $prefix), - $this->getRemark() - ) + $document->createElement(XmlHelper::getPrefixedTagName('remark', $prefix), $this->remark) ); } } - /** - * @param DOMDocument $document - * @param $prefix - * @param DOMElement $box - */ - private function additionalCustomerReferenceToXML(DOMDocument $document, $prefix, DOMElement $box) + private function additionalCustomerReferenceToXML(DOMDocument $document, ?string $prefix, DOMElement $box): void { - if ($this->getAdditionalCustomerReference() !== null) { + if ($this->additionalCustomerReference !== null) { $box->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('additionalCustomerReference', $prefix), - $this->getAdditionalCustomerReference() + $this->additionalCustomerReference ) ); } } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/At247.php b/src/Bpost/Order/Box/At247.php index b828b6fc..7a276de1 100644 --- a/src/Bpost/Order/Box/At247.php +++ b/src/Bpost/Order/Box/At247.php @@ -1,4 +1,5 @@ memberId = $memberId; } - /** - * @return string - */ - public function getMemberId() + public function getMemberId(): ?string { return $this->memberId; } - /** - * @param \Bpost\BpostApiClient\Bpost\Order\ParcelsDepotAddress $parcelsDepotAddress - */ - public function setParcelsDepotAddress($parcelsDepotAddress) + public function setParcelsDepotAddress(?ParcelsDepotAddress $parcelsDepotAddress): void { $this->parcelsDepotAddress = $parcelsDepotAddress; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\ParcelsDepotAddress - */ - public function getParcelsDepotAddress() + public function getParcelsDepotAddress(): ?ParcelsDepotAddress { return $this->parcelsDepotAddress; } - /** - * @param string $parcelsDepotId - */ - public function setParcelsDepotId($parcelsDepotId) + public function setParcelsDepotId(?string $parcelsDepotId): void { $this->parcelsDepotId = $parcelsDepotId; } - /** - * @return string - */ - public function getParcelsDepotId() + public function getParcelsDepotId(): ?string { return $this->parcelsDepotId; } - /** - * @param string $parcelsDepotName - */ - public function setParcelsDepotName($parcelsDepotName) + public function setParcelsDepotName(?string $parcelsDepotName): void { $this->parcelsDepotName = $parcelsDepotName; } - /** - * @return string - */ - public function getParcelsDepotName() + public function getParcelsDepotName(): ?string { return $this->parcelsDepotName; } - /** - * @return Unregistered - */ - public function getUnregistered() + public function getUnregistered(): ?Unregistered { return $this->unregistered; } - /** - * @param Unregistered $unregistered - */ - public function setUnregistered(Unregistered $unregistered) + public function setUnregistered(?Unregistered $unregistered): void { $this->unregistered = $unregistered; } /** - * @param string $product Possible values are: bpack 24h Pro - * * @throws BpostInvalidValueException */ - public function setProduct($product) + public function setProduct(string $product): void { - if (!in_array($product, self::getPossibleProductValues())) { + if (!in_array($product, self::getPossibleProductValues(), true)) { throw new BpostInvalidValueException('product', $product, self::getPossibleProductValues()); } - parent::setProduct($product); } - /** - * @return array - */ - public static function getPossibleProductValues() + public static function getPossibleProductValues(): array { - return array( + return [ Product::PRODUCT_NAME_BPACK_24H_PRO, Product::PRODUCT_NAME_BPACK_24_7, - ); + ]; } - /** - * @param string $receiverCompany - */ - public function setReceiverCompany($receiverCompany) + public function setReceiverCompany(?string $receiverCompany): void { $this->receiverCompany = $receiverCompany; } - /** - * @return string - */ - public function getReceiverCompany() + public function getReceiverCompany(): ?string { return $this->receiverCompany; } - /** - * @param string $receiverName - */ - public function setReceiverName($receiverName) + public function setReceiverName(?string $receiverName): void { $this->receiverName = $receiverName; } - /** - * @return string - */ - public function getReceiverName() + public function getReceiverName(): ?string { return $this->receiverName; } - /** - * @return string - */ - public function getRequestedDeliveryDate() + public function getRequestedDeliveryDate(): ?string { return $this->requestedDeliveryDate; } - /** - * @param string $requestedDeliveryDate - */ - public function setRequestedDeliveryDate($requestedDeliveryDate) + public function setRequestedDeliveryDate(?string $requestedDeliveryDate): void { - $this->requestedDeliveryDate = (string) $requestedDeliveryDate; + $this->requestedDeliveryDate = $requestedDeliveryDate; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * @param string $type - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = null, $type = null) + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { $nationalElement = $document->createElement(XmlHelper::getPrefixedTagName('nationalBox', $prefix)); $boxElement = parent::toXML($document, null, 'at24-7'); $nationalElement->appendChild($boxElement); - if ($this->getParcelsDepotId() !== null) { - $boxElement->appendChild( - $document->createElement('parcelsDepotId', $this->getParcelsDepotId()) - ); + if ($this->parcelsDepotId !== null) { + $boxElement->appendChild($document->createElement('parcelsDepotId', $this->parcelsDepotId)); } - if ($this->getParcelsDepotName() !== null) { - $boxElement->appendChild( - $document->createElement( - 'parcelsDepotName', - $this->getParcelsDepotName() - ) - ); + if ($this->parcelsDepotName !== null) { + $boxElement->appendChild($document->createElement('parcelsDepotName', $this->parcelsDepotName)); } - if ($this->getParcelsDepotAddress() !== null) { - $boxElement->appendChild( - $this->getParcelsDepotAddress()->toXML($document) - ); + if ($this->parcelsDepotAddress !== null) { + $boxElement->appendChild($this->parcelsDepotAddress->toXML($document)); } - if ($this->getMemberId() !== null) { - $boxElement->appendChild( - $document->createElement( - 'memberId', - $this->getMemberId() - ) - ); + if ($this->memberId !== null) { + $boxElement->appendChild($document->createElement('memberId', $this->memberId)); } + $this->addToXmlUnregistered($document, $boxElement, $prefix); - if ($this->getReceiverName() !== null) { - $boxElement->appendChild( - $document->createElement( - 'receiverName', - $this->getReceiverName() - ) - ); + + if ($this->receiverName !== null) { + $boxElement->appendChild($document->createElement('receiverName', $this->receiverName)); } - if ($this->getReceiverCompany() !== null) { - $boxElement->appendChild( - $document->createElement( - 'receiverCompany', - $this->getReceiverCompany() - ) - ); + if ($this->receiverCompany !== null) { + $boxElement->appendChild($document->createElement('receiverCompany', $this->receiverCompany)); } + $this->addToXmlRequestedDeliveryDate($document, $boxElement, $prefix); return $nationalElement; } - /** - * @param DOMDocument $document - * @param DOMElement $typeElement - * @param string $prefix - */ - protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement, $prefix) + protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement, ?string $prefix): void { - if ($this->getRequestedDeliveryDate() !== null && $this->getRequestedDeliveryDate() !== "" ) { + $date = $this->requestedDeliveryDate; + if ($date !== null && $date !== '') { $typeElement->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('requestedDeliveryDate', $prefix), - $this->getRequestedDeliveryDate() - ) + $document->createElement(XmlHelper::getPrefixedTagName('requestedDeliveryDate', $prefix), $date) ); } } /** - * @param DOMDocument $document - * @param DOMElement $typeElement - * @param string $prefix + * @throws \DOMException */ - protected function addToXmlUnregistered(DOMDocument $document, DOMElement $typeElement, $prefix) + protected function addToXmlUnregistered(DOMDocument $document, DOMElement $typeElement, ?string $prefix): void { - if ($this->getUnregistered() !== null) { - $typeElement->appendChild( - $this->getUnregistered()->toXml($document) - ); + if ($this->unregistered !== null) { + $typeElement->appendChild($this->unregistered->toXml($document, $prefix, null)); } } /** - * @param SimpleXMLElement $xml - * @param National|null $self - * - * @return At247 - * * @throws BpostInvalidValueException * @throws BpostNotImplementedException - * @throws \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException - * @throws \Bpost\BpostApiClient\Exception\XmlException\BpostXmlInvalidItemException + * @throws BpostInvalidLengthException */ - public static function createFromXML(SimpleXMLElement $xml, National $self = null) + public static function createFromXML(SimpleXMLElement $xml, ?National $self = null): At247 { $at247 = new At247(); - if (isset($xml->{'at24-7'}->product) && $xml->{'at24-7'}->product != '') { - $at247->setProduct( - (string) $xml->{'at24-7'}->product - ); + if (isset($xml->{'at24-7'}->product) && (string)$xml->{'at24-7'}->product !== '') { + $at247->setProduct((string)$xml->{'at24-7'}->product); } + if (isset($xml->{'at24-7'}->options)) { - /** @var SimpleXMLElement $optionData */ foreach ($xml->{'at24-7'}->options as $optionData) { $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common'); - if (in_array($optionData->getName(), array(Messaging::MESSAGING_TYPE_INFO_DISTRIBUTED))) { + if ($optionData->getName() === Messaging::MESSAGING_TYPE_INFO_DISTRIBUTED) { $option = Messaging::createFromXML($optionData); } else { $option = self::getOptionFromOptionData($optionData); @@ -333,49 +220,32 @@ public static function createFromXML(SimpleXMLElement $xml, National $self = nul $at247->addOption($option); } } - if (isset($xml->{'at24-7'}->weight) && $xml->{'at24-7'}->weight != '') { - $at247->setWeight( - (int) $xml->{'at24-7'}->weight - ); + + if (isset($xml->{'at24-7'}->weight) && (string)$xml->{'at24-7'}->weight !== '') { + $at247->setWeight((int)$xml->{'at24-7'}->weight); } - if (isset($xml->{'at24-7'}->memberId) && $xml->{'at24-7'}->memberId != '') { - $at247->setMemberId( - (string) $xml->{'at24-7'}->memberId - ); + if (isset($xml->{'at24-7'}->memberId) && (string)$xml->{'at24-7'}->memberId !== '') { + $at247->setMemberId((string)$xml->{'at24-7'}->memberId); } - if (isset($xml->{'at24-7'}->receiverName) && $xml->{'at24-7'}->receiverName != '') { - $at247->setReceiverName( - (string) $xml->{'at24-7'}->receiverName - ); + if (isset($xml->{'at24-7'}->receiverName) && (string)$xml->{'at24-7'}->receiverName !== '') { + $at247->setReceiverName((string)$xml->{'at24-7'}->receiverName); } - if (isset($xml->{'at24-7'}->receiverCompany) && $xml->{'at24-7'}->receiverCompany != '') { - $at247->setReceiverCompany( - (string) $xml->{'at24-7'}->receiverCompany - ); + if (isset($xml->{'at24-7'}->receiverCompany) && (string)$xml->{'at24-7'}->receiverCompany !== '') { + $at247->setReceiverCompany((string)$xml->{'at24-7'}->receiverCompany); } - if (isset($xml->{'at24-7'}->parcelsDepotId) && $xml->{'at24-7'}->parcelsDepotId != '') { - $at247->setParcelsDepotId( - (string) $xml->{'at24-7'}->parcelsDepotId - ); + if (isset($xml->{'at24-7'}->parcelsDepotId) && (string)$xml->{'at24-7'}->parcelsDepotId !== '') { + $at247->setParcelsDepotId((string)$xml->{'at24-7'}->parcelsDepotId); } - if (isset($xml->{'at24-7'}->parcelsDepotName) && $xml->{'at24-7'}->parcelsDepotName != '') { - $at247->setParcelsDepotName( - (string) $xml->{'at24-7'}->parcelsDepotName - ); + if (isset($xml->{'at24-7'}->parcelsDepotName) && (string)$xml->{'at24-7'}->parcelsDepotName !== '') { + $at247->setParcelsDepotName((string)$xml->{'at24-7'}->parcelsDepotName); } if (isset($xml->{'at24-7'}->parcelsDepotAddress)) { - /** @var SimpleXMLElement $parcelsDepotAddressData */ - $parcelsDepotAddressData = $xml->{'at24-7'}->parcelsDepotAddress->children( - 'http://schema.post.be/shm/deepintegration/v3/common' - ); - $at247->setParcelsDepotAddress( - ParcelsDepotAddress::createFromXML($parcelsDepotAddressData) - ); + $parcelsDepotAddressData = $xml->{'at24-7'}->parcelsDepotAddress + ->children('http://schema.post.be/shm/deepintegration/v3/common'); + $at247->setParcelsDepotAddress(ParcelsDepotAddress::createFromXML($parcelsDepotAddressData)); } - if (isset($xml->{'at24-7'}->requestedDeliveryDate) && $xml->{'at24-7'}->requestedDeliveryDate != '') { - $at247->setRequestedDeliveryDate( - (string) $xml->{'at24-7'}->requestedDeliveryDate - ); + if (isset($xml->{'at24-7'}->requestedDeliveryDate) && (string)$xml->{'at24-7'}->requestedDeliveryDate !== '') { + $at247->setRequestedDeliveryDate((string)$xml->{'at24-7'}->requestedDeliveryDate); } return $at247; diff --git a/src/Bpost/Order/Box/AtBpost.php b/src/Bpost/Order/Box/AtBpost.php index c144eb58..ef5d34b8 100644 --- a/src/Bpost/Order/Box/AtBpost.php +++ b/src/Bpost/Order/Box/AtBpost.php @@ -1,4 +1,5 @@ pugoAddress = $pugoAddress; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\PugoAddress - */ - public function getPugoAddress() + public function getPugoAddress(): ?PugoAddress { return $this->pugoAddress; } - /** - * @param string $pugoId - */ - public function setPugoId($pugoId) + public function setPugoId(?string $pugoId): void { $this->pugoId = $pugoId; } - /** - * @return string - */ - public function getPugoId() + public function getPugoId(): ?string { return $this->pugoId; } - /** - * @param string $pugoName - */ - public function setPugoName($pugoName) + public function setPugoName(?string $pugoName): void { $this->pugoName = $pugoName; } - /** - * @return string - */ - public function getPugoName() + public function getPugoName(): ?string { return $this->pugoName; } - /** - * @param string $receiverCompany - */ - public function setReceiverCompany($receiverCompany) + public function setReceiverCompany(?string $receiverCompany): void { $this->receiverCompany = $receiverCompany; } - /** - * @return string - */ - public function getReceiverCompany() + public function getReceiverCompany(): ?string { return $this->receiverCompany; } - /** - * @param string $receiverName - */ - public function setReceiverName($receiverName) + public function setReceiverName(?string $receiverName): void { $this->receiverName = $receiverName; } - /** - * @return string - */ - public function getReceiverName() + public function getReceiverName(): ?string { return $this->receiverName; } - /** - * @return string - */ - public function getRequestedDeliveryDate() + public function getRequestedDeliveryDate(): ?string { return $this->requestedDeliveryDate; } - /** - * @param string $requestedDeliveryDate - */ - public function setRequestedDeliveryDate($requestedDeliveryDate) + public function setRequestedDeliveryDate(?string $requestedDeliveryDate): void { $this->requestedDeliveryDate = $requestedDeliveryDate; } - /** - * @return string - */ - public function getShopHandlingInstruction() + public function getShopHandlingInstruction(): ?string { - if ($this->shopHandlingInstruction !== null) { - return $this->shopHandlingInstruction->getValue(); - } - - return null; + return $this->shopHandlingInstruction?->getValue(); } - /** - * @param string $shopHandlingInstruction - */ - public function setShopHandlingInstruction($shopHandlingInstruction) + public function setShopHandlingInstruction(?string $shopHandlingInstruction): void { - $this->shopHandlingInstruction = new ShopHandlingInstruction($shopHandlingInstruction); + $this->shopHandlingInstruction = $shopHandlingInstruction !== null + ? new ShopHandlingInstruction($shopHandlingInstruction) + : null; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * @param string $type - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = null, $type = null) + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { $nationalElement = $document->createElement(XmlHelper::getPrefixedTagName('nationalBox', $prefix)); $boxElement = parent::toXML($document, null, 'atBpost'); $nationalElement->appendChild($boxElement); - if ($this->getPugoId() !== null) { - $boxElement->appendChild( - $document->createElement('pugoId', $this->getPugoId()) - ); + if ($this->pugoId !== null) { + $boxElement->appendChild($document->createElement('pugoId', $this->pugoId)); } - if ($this->getPugoName() !== null) { - $boxElement->appendChild( - $document->createElement('pugoName', $this->getPugoName()) - ); + if ($this->pugoName !== null) { + $boxElement->appendChild($document->createElement('pugoName', $this->pugoName)); } - if ($this->getPugoAddress() !== null) { - $boxElement->appendChild( - $this->getPugoAddress()->toXML($document, 'common') - ); + if ($this->pugoAddress !== null) { + $boxElement->appendChild($this->pugoAddress->toXML($document)); } - if ($this->getReceiverName() !== null) { - $boxElement->appendChild( - $document->createElement('receiverName', $this->getReceiverName()) - ); + if ($this->receiverName !== null) { + $boxElement->appendChild($document->createElement('receiverName', $this->receiverName)); } - if ($this->getReceiverCompany() !== null) { - $boxElement->appendChild( - $document->createElement('receiverCompany', $this->getReceiverCompany()) - ); + if ($this->receiverCompany !== null) { + $boxElement->appendChild($document->createElement('receiverCompany', $this->receiverCompany)); } + $this->addToXmlRequestedDeliveryDate($document, $boxElement, $prefix); $this->addToXmlShopHandlingInstruction($document, $boxElement, $prefix); @@ -236,63 +158,52 @@ public function toXML(DOMDocument $document, $prefix = null, $type = null) } /** - * @param DOMDocument $document - * @param DOMElement $typeElement - * @param string $prefix + * @throws \DOMException */ - protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement, $prefix) + protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement, ?string $prefix): void { - if ($this->getRequestedDeliveryDate() !== null) { + if ($this->requestedDeliveryDate !== null) { $typeElement->appendChild( - $document->createElement('requestedDeliveryDate', $this->getRequestedDeliveryDate()) + $document->createElement('requestedDeliveryDate', $this->requestedDeliveryDate) ); } } - private function addToXmlShopHandlingInstruction(DOMDocument $document, DOMElement $typeElement, $prefix) + private function addToXmlShopHandlingInstruction(DOMDocument $document, DOMElement $typeElement, ?string $prefix): void { - if ($this->getShopHandlingInstruction() !== null) { - $typeElement->appendChild( - $document->createElement('shopHandlingInstruction', $this->getShopHandlingInstruction()) - ); + $value = $this->getShopHandlingInstruction(); + if ($value !== null) { + $typeElement->appendChild($document->createElement('shopHandlingInstruction', $value)); } } /** - * @param SimpleXMLElement $xml - * @param National|null $self - * - * @return AtBpost - * * @throws BpostInvalidValueException * @throws BpostNotImplementedException - * @throws \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException - * @throws \Bpost\BpostApiClient\Exception\XmlException\BpostXmlInvalidItemException + * @throws BpostInvalidLengthException */ - public static function createFromXML(SimpleXMLElement $xml, National $self = null) + public static function createFromXML(SimpleXMLElement $xml, National $self = null): AtBpost { $atBpost = new AtBpost(); - if (isset($xml->atBpost->product) && $xml->atBpost->product != '') { - $atBpost->setProduct( - (string) $xml->atBpost->product - ); + if (isset($xml->atBpost->product) && (string)$xml->atBpost->product !== '') { + $atBpost->setProduct((string)$xml->atBpost->product); } + if (isset($xml->atBpost->options)) { - /** @var SimpleXMLElement $optionData */ foreach ($xml->atBpost->options as $optionData) { $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common'); if (in_array( $optionData->getName(), - array( + [ Messaging::MESSAGING_TYPE_INFO_DISTRIBUTED, Messaging::MESSAGING_TYPE_INFO_NEXT_DAY, Messaging::MESSAGING_TYPE_INFO_REMINDER, Messaging::MESSAGING_TYPE_KEEP_ME_INFORMED, - ) - ) - ) { + ], + true + )) { $option = Messaging::createFromXML($optionData); } else { $option = self::getOptionFromOptionData($optionData); @@ -301,51 +212,34 @@ public static function createFromXML(SimpleXMLElement $xml, National $self = nul $atBpost->addOption($option); } } - if (isset($xml->atBpost->weight) && $xml->atBpost->weight != '') { - $atBpost->setWeight( - (int) $xml->atBpost->weight - ); + + if (isset($xml->atBpost->weight) && (string)$xml->atBpost->weight !== '') { + $atBpost->setWeight((int)$xml->atBpost->weight); } - if (isset($xml->atBpost->receiverName) && $xml->atBpost->receiverName != '') { - $atBpost->setReceiverName( - (string) $xml->atBpost->receiverName - ); + if (isset($xml->atBpost->receiverName) && (string)$xml->atBpost->receiverName !== '') { + $atBpost->setReceiverName((string)$xml->atBpost->receiverName); } - if (isset($xml->atBpost->receiverCompany) && $xml->atBpost->receiverCompany != '') { - $atBpost->setReceiverCompany( - (string) $xml->atBpost->receiverCompany - ); + if (isset($xml->atBpost->receiverCompany) && (string)$xml->atBpost->receiverCompany !== '') { + $atBpost->setReceiverCompany((string)$xml->atBpost->receiverCompany); } - if (isset($xml->atBpost->pugoId) && $xml->atBpost->pugoId != '') { - $atBpost->setPugoId( - (string) $xml->atBpost->pugoId - ); + if (isset($xml->atBpost->pugoId) && (string)$xml->atBpost->pugoId !== '') { + $atBpost->setPugoId((string)$xml->atBpost->pugoId); } - if (isset($xml->atBpost->pugoName) && $xml->atBpost->pugoName != '') { - $atBpost->setPugoName( - (string) $xml->atBpost->pugoName - ); + if (isset($xml->atBpost->pugoName) && (string)$xml->atBpost->pugoName !== '') { + $atBpost->setPugoName((string)$xml->atBpost->pugoName); } if (isset($xml->atBpost->pugoAddress)) { - /** @var SimpleXMLElement $pugoAddressData */ - $pugoAddressData = $xml->atBpost->pugoAddress->children( - 'http://schema.post.be/shm/deepintegration/v3/common' - ); - $atBpost->setPugoAddress( - PugoAddress::createFromXML($pugoAddressData) - ); + $pugoAddressData = $xml->atBpost->pugoAddress + ->children('http://schema.post.be/shm/deepintegration/v3/common'); + $atBpost->setPugoAddress(PugoAddress::createFromXML($pugoAddressData)); } - if (isset($xml->atBpost->requestedDeliveryDate) && $xml->atBpost->requestedDeliveryDate != '') { - $atBpost->setRequestedDeliveryDate( - (string) $xml->atBpost->requestedDeliveryDate - ); + if (isset($xml->atBpost->requestedDeliveryDate) && (string)$xml->atBpost->requestedDeliveryDate !== '') { + $atBpost->setRequestedDeliveryDate((string)$xml->atBpost->requestedDeliveryDate); } - if (isset($xml->atBpost->shopHandlingInstruction) && $xml->atBpost->shopHandlingInstruction != '') { - $atBpost->setShopHandlingInstruction( - (string) $xml->atBpost->shopHandlingInstruction - ); + if (isset($xml->atBpost->shopHandlingInstruction) && (string)$xml->atBpost->shopHandlingInstruction !== '') { + $atBpost->setShopHandlingInstruction((string)$xml->atBpost->shopHandlingInstruction); } return $atBpost; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/AtHome.php b/src/Bpost/Order/Box/AtHome.php index a8e01a1e..d9cb1f3b 100644 --- a/src/Bpost/Order/Box/AtHome.php +++ b/src/Bpost/Order/Box/AtHome.php @@ -1,4 +1,5 @@ receiver = $receiver; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\Receiver - */ - public function getReceiver() + public function getReceiver(): ?Receiver { return $this->receiver; } - /** - * @return string - */ - public function getRequestedDeliveryDate() + public function getRequestedDeliveryDate(): ?string { return $this->requestedDeliveryDate; } - /** - * @param string $requestedDeliveryDate - */ - public function setRequestedDeliveryDate($requestedDeliveryDate) + public function setRequestedDeliveryDate(?string $requestedDeliveryDate): void { - $this->requestedDeliveryDate = (string) $requestedDeliveryDate; + $this->requestedDeliveryDate = $requestedDeliveryDate; } - /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * @param string $type - * - * @return DomElement - */ - public function toXML(DOMDocument $document, $prefix = null, $type = null) + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { $nationalElement = $document->createElement(XmlHelper::getPrefixedTagName('nationalBox', $prefix)); $boxElement = parent::toXML($document, null, 'atHome'); $nationalElement->appendChild($boxElement); - if ($this->getReceiver() !== null) { - $boxElement->appendChild( - $this->getReceiver()->toXML($document) - ); + if ($this->receiver !== null) { + $boxElement->appendChild($this->receiver->toXML($document)); } $this->addToXmlRequestedDeliveryDate($document, $boxElement); @@ -118,31 +85,18 @@ public function toXML(DOMDocument $document, $prefix = null, $type = null) } /** - * @param DOMDocument $document - * @param DOMElement $typeElement + * @throws \DOMException */ - protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement) + protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement): void { - if ($this->getRequestedDeliveryDate() !== null) { + if ($this->requestedDeliveryDate !== null) { $typeElement->appendChild( - $document->createElement( - 'requestedDeliveryDate', - $this->getRequestedDeliveryDate() - ) + $document->createElement('requestedDeliveryDate', $this->requestedDeliveryDate) ); } } - /** - * @param SimpleXMLElement $xml - * @param National $self - * - * @return AtHome - * - * @throws BpostXmlInvalidItemException - * @throws \Bpost\BpostApiClient\BpostException - */ - public static function createFromXML(SimpleXMLElement $xml, National $self = null) + public static function createFromXML(SimpleXMLElement $xml, National $self = null): AtHome { if ($self === null) { $self = new self(); @@ -154,6 +108,7 @@ public static function createFromXML(SimpleXMLElement $xml, National $self = nul $atHomeXml = $xml->atHome[0]; + /** @var AtHome $self */ $self = parent::createFromXML($atHomeXml, $self); if (isset($atHomeXml->receiver)) { @@ -164,10 +119,8 @@ public static function createFromXML(SimpleXMLElement $xml, National $self = nul ); } - if (isset($atHomeXml->requestedDeliveryDate) && $atHomeXml->requestedDeliveryDate != '') { - $self->setRequestedDeliveryDate( - $atHomeXml->requestedDeliveryDate - ); + if (isset($atHomeXml->requestedDeliveryDate) && (string)$atHomeXml->requestedDeliveryDate !== '') { + $self->setRequestedDeliveryDate((string)$atHomeXml->requestedDeliveryDate); } return $self; diff --git a/src/Bpost/Order/Box/BpostOnAppointment.php b/src/Bpost/Order/Box/BpostOnAppointment.php index 39a3b7d1..283882ab 100644 --- a/src/Bpost/Order/Box/BpostOnAppointment.php +++ b/src/Bpost/Order/Box/BpostOnAppointment.php @@ -1,4 +1,5 @@ receiver = $receiver; } - /** - * @return Receiver - */ - public function getReceiver() + public function getReceiver(): ?Receiver { return $this->receiver; } - /** - * @return string - */ - public function getInNetworkCutOff() + public function getInNetworkCutOff(): ?string { return $this->inNetworkCutOff; } - /** - * @param string $inNetworkCutOff - */ - public function setInNetworkCutOff($inNetworkCutOff) + public function setInNetworkCutOff(?string $inNetworkCutOff): void { - $this->inNetworkCutOff = (string) $inNetworkCutOff; + $this->inNetworkCutOff = $inNetworkCutOff; } - /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * @param string $type - * - * @return DomElement - */ - public function toXML(DOMDocument $document, $prefix = null, $type = null) + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { $nationalElement = $document->createElement(XmlHelper::getPrefixedTagName('nationalBox', $prefix)); $boxElement = parent::toXML($document, null, 'bpostOnAppointment'); $nationalElement->appendChild($boxElement); $this->addToXmlReceiver($document, $boxElement); - $this->addToXmlRequestedDeliveryDate($document, $boxElement, $prefix); return $nationalElement; } - /** - * @param DOMDocument $document - * @param DOMElement $typeElement - */ - protected function addToXmlReceiver(DOMDocument $document, DOMElement $typeElement) + protected function addToXmlReceiver(DOMDocument $document, DOMElement $typeElement): void { - if ($this->getReceiver() !== null) { - $typeElement->appendChild( - $this->getReceiver()->toXML($document) - ); + if ($this->receiver !== null) { + $typeElement->appendChild($this->receiver->toXML($document)); } } /** - * @param DOMDocument $document - * @param DOMElement $typeElement - * @param string $prefix + * @throws \DOMException */ - protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement, $prefix) + protected function addToXmlRequestedDeliveryDate(DOMDocument $document, DOMElement $typeElement, ?string $prefix): void { - if ($this->getInNetworkCutOff() !== null) { + if ($this->inNetworkCutOff !== null && $this->inNetworkCutOff !== '') { $typeElement->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('inNetworkCutOff', $prefix), - $this->getInNetworkCutOff() + $this->inNetworkCutOff ) ); } } - /** - * @param SimpleXMLElement $xml - * @param National|null $self - * - * @return BpostOnAppointment - * - * @throws BpostXmlInvalidItemException - */ - public static function createFromXML(SimpleXMLElement $xml, National $self = null) + public static function createFromXML(SimpleXMLElement $xml, National $self = null): BpostOnAppointment { $self = new self(); @@ -130,12 +90,10 @@ public static function createFromXML(SimpleXMLElement $xml, National $self = nul ); } - if (isset($bpostOnAppointmentXml->inNetworkCutOff) && $bpostOnAppointmentXml->inNetworkCutOff != '') { - $self->setInNetworkCutOff( - (string) $bpostOnAppointmentXml->inNetworkCutOff - ); + if (isset($bpostOnAppointmentXml->inNetworkCutOff) && (string)$bpostOnAppointmentXml->inNetworkCutOff !== '') { + $self->setInNetworkCutOff((string)$bpostOnAppointmentXml->inNetworkCutOff); } return $self; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php b/src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php index 332c1d0b..78f99ab3 100644 --- a/src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php +++ b/src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php @@ -1,4 +1,5 @@ contentDescription = null; + return; + } $length = 50; if (mb_strlen($contentDescription) > $length) { throw new BpostInvalidLengthException('contentDescription', mb_strlen($contentDescription), $length); } - $this->contentDescription = $contentDescription; } - /** - * @return string - */ - public function getContentDescription() + public function getContentDescription(): ?string { return $this->contentDescription; } /** - * @param string $parcelReturnInstructions - * * @throws BpostInvalidValueException */ - public function setParcelReturnInstructions($parcelReturnInstructions) + public function setParcelReturnInstructions(?string $parcelReturnInstructions): void { - $parcelReturnInstructions = strtoupper($parcelReturnInstructions); + if ($parcelReturnInstructions === null) { + $this->parcelReturnInstructions = null; + return; + } - if (!in_array($parcelReturnInstructions, self::getPossibleParcelReturnInstructionValues())) { + $normalized = strtoupper($parcelReturnInstructions); + if (!in_array($normalized, self::getPossibleParcelReturnInstructionValues(), true)) { throw new BpostInvalidValueException( 'parcelReturnInstructions', - $parcelReturnInstructions, + $normalized, self::getPossibleParcelReturnInstructionValues() ); } - - $this->parcelReturnInstructions = $parcelReturnInstructions; + $this->parcelReturnInstructions = $normalized; } - /** - * @return string - */ - public function getParcelReturnInstructions() + public function getParcelReturnInstructions(): ?string { return $this->parcelReturnInstructions; } - /** - * @return array - */ - public static function getPossibleParcelReturnInstructionValues() + public static function getPossibleParcelReturnInstructionValues(): array { - return array( + return [ self::CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTA, self::CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTS, self::CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_ABANDONED, - ); + ]; } - /** - * @param int $parcelValue - */ - public function setParcelValue($parcelValue) + public function setParcelValue(?int $parcelValue): void { $this->parcelValue = $parcelValue; } - /** - * @return int - */ - public function getParcelValue() + public function getParcelValue(): ?int { return $this->parcelValue; } - /** - * @param bool $privateAddress - */ - public function setPrivateAddress($privateAddress) + public function setPrivateAddress(?bool $privateAddress): void { $this->privateAddress = $privateAddress; } - /** - * @return bool - */ - public function getPrivateAddress() + public function getPrivateAddress(): ?bool { return $this->privateAddress; } /** - * @param string $shipmentType - * * @throws BpostInvalidValueException */ - public function setShipmentType($shipmentType) + public function setShipmentType(?string $shipmentType): void { - $shipmentType = strtoupper($shipmentType); - - if (!in_array($shipmentType, self::getPossibleShipmentTypeValues())) { - throw new BpostInvalidValueException('shipmentType', $shipmentType, self::getPossibleShipmentTypeValues()); + if ($shipmentType === null) { + $this->shipmentType = null; + return; } - $this->shipmentType = $shipmentType; + $normalized = strtoupper($shipmentType); + if (!in_array($normalized, self::getPossibleShipmentTypeValues(), true)) { + throw new BpostInvalidValueException('shipmentType', $normalized, self::getPossibleShipmentTypeValues()); + } + $this->shipmentType = $normalized; } - /** - * @return string - */ - public function getShipmentType() + public function getShipmentType(): ?string { return $this->shipmentType; } + /** * @return array */ - public static function getPossibleShipmentTypeValues() + public static function getPossibleShipmentTypeValues(): array { - return array( + return [ self::CUSTOM_INFO_SHIPMENT_TYPE_SAMPLE, self::CUSTOM_INFO_SHIPMENT_TYPE_GIFT, self::CUSTOM_INFO_SHIPMENT_TYPE_GOODS, self::CUSTOM_INFO_SHIPMENT_TYPE_DOCUMENTS, self::CUSTOM_INFO_SHIPMENT_TYPE_OTHER, - ); + ]; } - /** - * @return float - */ - public function getAmtPostagePaidByAddresse() + public function getAmtPostagePaidByAddresse(): ?float { return $this->amtPostagePaidByAddresse; } - /** - * @param float $amtPostagePaidByAddresse - */ - public function setAmtPostagePaidByAddresse($amtPostagePaidByAddresse) + public function setAmtPostagePaidByAddresse(?float $amtPostagePaidByAddresse): void { $this->amtPostagePaidByAddresse = $amtPostagePaidByAddresse; } - /** - * @return string - */ - public function getCurrency() + public function getCurrency(): ?string { return $this->currency; } + /** - * @param string $currency - * * @throws BpostInvalidValueException */ - public function setCurrency($currency) + public function setCurrency(?string $currency): void { - if (!in_array($currency, self::getPossibleCurrencyValues())) { + if ($currency === null) { + $this->currency = null; + return; + } + if (!in_array($currency, self::getPossibleCurrencyValues(), true)) { throw new BpostInvalidValueException('currency', $currency, self::getPossibleCurrencyValues()); } $this->currency = $currency; } - public static function getPossibleCurrencyValues() + public static function getPossibleCurrencyValues(): array { - return array( + return [ self::CUSTOM_INFO_CURRENCY_EUR, self::CUSTOM_INFO_CURRENCY_GBP, self::CUSTOM_INFO_CURRENCY_USD, self::CUSTOM_INFO_CURRENCY_CNY, - ); + ]; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement - * * @throws DOMException */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement { $customsInfo = $document->createElement(XmlHelper::getPrefixedTagName('customsInfo', $prefix)); @@ -289,83 +237,53 @@ public function toXML(DOMDocument $document, $prefix = null) } /** - * @param SimpleXMLElement $xml - * - * @return CustomsInfo - * * @throws BpostInvalidLengthException * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - $customsInfo = new CustomsInfo(); + $customsInfo = new self(); - if (isset($xml->parcelValue) && $xml->parcelValue != '') { - $customsInfo->setParcelValue( - (int) $xml->parcelValue - ); + if (isset($xml->parcelValue) && (string)$xml->parcelValue !== '') { + $customsInfo->setParcelValue((int)$xml->parcelValue); } - if (isset($xml->contentDescription) && $xml->contentDescription != '') { - $customsInfo->setContentDescription( - (string) $xml->contentDescription - ); + if (isset($xml->contentDescription) && (string)$xml->contentDescription !== '') { + $customsInfo->setContentDescription((string)$xml->contentDescription); } - if (isset($xml->shipmentType) && $xml->shipmentType != '') { - $customsInfo->setShipmentType( - (string) $xml->shipmentType - ); + if (isset($xml->shipmentType) && (string)$xml->shipmentType !== '') { + $customsInfo->setShipmentType((string)$xml->shipmentType); } - if (isset($xml->parcelReturnInstructions) && $xml->parcelReturnInstructions != '') { - $customsInfo->setParcelReturnInstructions( - (string) $xml->parcelReturnInstructions - ); + if (isset($xml->parcelReturnInstructions) && (string)$xml->parcelReturnInstructions !== '') { + $customsInfo->setParcelReturnInstructions((string)$xml->parcelReturnInstructions); } - if (isset($xml->privateAddress) && $xml->privateAddress != '') { - $customsInfo->setPrivateAddress( - (string) $xml->privateAddress == 'true' - ); + if (isset($xml->privateAddress) && (string)$xml->privateAddress !== '') { + $customsInfo->setPrivateAddress(in_array((string)$xml->privateAddress, ['true', '1'], true)); } - if (isset($xml->currency) && $xml->currency != '') { - $customsInfo->setCurrency( - (string) $xml->currency - ); + if (isset($xml->currency) && (string)$xml->currency !== '') { + $customsInfo->setCurrency((string)$xml->currency); } - if (isset($xml->amtPostagePaidByAddresse) && $xml->amtPostagePaidByAddresse != '') { - $customsInfo->setAmtPostagePaidByAddresse( - (float) $xml->amtPostagePaidByAddresse - ); + if (isset($xml->amtPostagePaidByAddresse) && (string)$xml->amtPostagePaidByAddresse !== '') { + $customsInfo->setAmtPostagePaidByAddresse((float)$xml->amtPostagePaidByAddresse); } return $customsInfo; } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function parcelValueToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function parcelValueToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getParcelValue() !== null) { $customsInfo->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('parcelValue', $prefix), - $this->getParcelValue() + (string)$this->getParcelValue() ) ); } } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function currencyToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function currencyToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getCurrency() !== null) { $customsInfo->appendChild( @@ -377,14 +295,8 @@ private function currencyToXML(DOMDocument $document, $prefix, DOMElement $custo } } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function amtPostagePaidByAddresseToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function amtPostagePaidByAddresseToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getAmtPostagePaidByAddresse() !== null) { $customsInfo->appendChild( @@ -396,14 +308,8 @@ private function amtPostagePaidByAddresseToXML(DOMDocument $document, $prefix, D } } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function contentDescriptionToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function contentDescriptionToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getContentDescription() !== null) { $customsInfo->appendChild( @@ -415,14 +321,8 @@ private function contentDescriptionToXML(DOMDocument $document, $prefix, DOMElem } } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function shipmentTypeToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function shipmentTypeToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getShipmentType() !== null) { $customsInfo->appendChild( @@ -434,14 +334,8 @@ private function shipmentTypeToXML(DOMDocument $document, $prefix, DOMElement $c } } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function parcelReturnInstructionValuesToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function parcelReturnInstructionValuesToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getParcelReturnInstructions() !== null) { $customsInfo->appendChild( @@ -453,21 +347,11 @@ private function parcelReturnInstructionValuesToXML(DOMDocument $document, $pref } } - /** - * @param DOMDocument $document - * @param string $prefix - * @param DOMElement $customsInfo - * - * @throws DOMException - */ - private function privateAddressToXML(DOMDocument $document, $prefix, DOMElement $customsInfo) + /** @throws DOMException */ + private function privateAddressToXML(DOMDocument $document, ?string $prefix, DOMElement $customsInfo): void { if ($this->getPrivateAddress() !== null) { - if ($this->getPrivateAddress()) { - $value = 'true'; - } else { - $value = 'false'; - } + $value = $this->getPrivateAddress() ? 'true' : 'false'; $customsInfo->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('privateAddress', $prefix), diff --git a/src/Bpost/Order/Box/IBox.php b/src/Bpost/Order/Box/IBox.php index 309f11ac..74b9ce1a 100644 --- a/src/Bpost/Order/Box/IBox.php +++ b/src/Bpost/Order/Box/IBox.php @@ -1,9 +1,11 @@ customsInfo = $customsInfo; } - /** - * @return CustomsInfo - */ - public function getCustomsInfo() + public function getCustomsInfo(): ?CustomsInfo { return $this->customsInfo; } - /** - * @param Option[] $options - */ - public function setOptions($options) + public function setOptions(array $options): void { $this->options = $options; } - /** - * @return Option[] - */ - public function getOptions() + public function getOptions(): array { return $this->options; } - /** - * @param Option $option - */ - public function addOption(Option $option) + public function addOption(Option $option): void { $this->options[] = $option; } - /** - * @param int $parcelWeight - */ - public function setParcelWeight($parcelWeight) + public function setParcelWeight(?int $parcelWeight): void { $this->parcelWeight = $parcelWeight; } - /** - * @return int - */ - public function getParcelWeight() + public function getParcelWeight(): ?int { return $this->parcelWeight; } /** - * @param string $product - * * @throws BpostInvalidValueException */ - public function setProduct($product) + public function setProduct(string $product): void { - if (!in_array($product, self::getPossibleProductValues())) { + if (!in_array($product, self::getPossibleProductValues(), true)) { throw new BpostInvalidValueException('product', $product, self::getPossibleProductValues()); } - $this->product = $product; } - /** - * @return string - */ - public function getProduct() + public function getProduct(): ?string { return $this->product; } - /** - * @return array - */ - public static function getPossibleProductValues() + public static function getPossibleProductValues(): array { - return array( + return [ Product::PRODUCT_NAME_BPACK_WORLD_BUSINESS, Product::PRODUCT_NAME_BPACK_WORLD_EASY_RETURN, Product::PRODUCT_NAME_BPACK_WORLD_EXPRESS_PRO, Product::PRODUCT_NAME_BPACK_EUROPE_BUSINESS, Product::PRODUCT_NAME_BPACK_AT_BPOST_INTERNATIONAL, - ); + ]; } - /** - * @param Receiver $receiver - */ - public function setReceiver($receiver) + public function setReceiver(?Receiver $receiver): void { $this->receiver = $receiver; } - /** - * @return Receiver - */ - public function getReceiver() + public function getReceiver(): ?Receiver { return $this->receiver; } - /** - * @return array|ParcelContent[] - */ - public function getParcelContents() + public function getParcelContents(): array { return $this->parcelContents; } /** - * @param array|ParcelContent[] $parcelContents - * - * @return self - * * @throws BpostInvalidValueException */ - public function setParcelContents(array $parcelContents) + public function setParcelContents(array $parcelContents): self { foreach ($parcelContents as $parcelContent) { if (!$parcelContent instanceof ParcelContent) { throw new BpostInvalidValueException( 'parcelContents', - get_class($parcelContent), - array('Bpost\BpostApiClient\Bpost\Order\Box\International\ParcelContent') + is_object($parcelContent) ? get_class($parcelContent) : gettype($parcelContent), + ['Bpost\\BpostApiClient\\Bpost\\Order\\Box\\International\\ParcelContent'] ); } - $this->addParcelContent($parcelContent); } - return $this; } - public function addParcelContent(ParcelContent $parcelContent) + public function addParcelContent(ParcelContent $parcelContent): void { $this->parcelContents[] = $parcelContent; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DOMElement - * * @throws DOMException */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { $internationalBox = $document->createElement(XmlHelper::getPrefixedTagName('internationalBox', $prefix)); - $prefix = 'international'; - $international = $document->createElement(XmlHelper::getPrefixedTagName('international', $prefix)); + $innerPrefix = 'international'; + $international = $document->createElement(XmlHelper::getPrefixedTagName('international', $innerPrefix)); $internationalBox->appendChild($international); - if ($this->getProduct() !== null) { + if ($this->product !== null) { $international->appendChild( - $document->createElement(XmlHelper::getPrefixedTagName('product', $prefix), $this->getProduct()) + $document->createElement(XmlHelper::getPrefixedTagName('product', $innerPrefix), $this->product) ); } - $options = $this->getOptions(); - if (!empty($options)) { - $optionsElement = $document->createElement(XmlHelper::getPrefixedTagName('options', $prefix)); - foreach ($options as $option) { - $optionsElement->appendChild( - $option->toXML($document, 'common') - ); + if (!empty($this->options)) { + $optionsElement = $document->createElement(XmlHelper::getPrefixedTagName('options', $innerPrefix)); + foreach ($this->options as $option) { + $optionsElement->appendChild($option->toXML($document, 'common')); } $international->appendChild($optionsElement); } - if ($this->getReceiver() !== null) { - $international->appendChild( - $this->getReceiver()->toXML($document, $prefix) - ); + if ($this->receiver !== null) { + $international->appendChild($this->receiver->toXML($document, $innerPrefix)); } - if ($this->getParcelWeight() !== null) { + if ($this->parcelWeight !== null) { $international->appendChild( $document->createElement( - XmlHelper::getPrefixedTagName('parcelWeight', $prefix), - $this->getParcelWeight() + XmlHelper::getPrefixedTagName('parcelWeight', $innerPrefix), + (string)$this->parcelWeight ) ); } - if ($this->getCustomsInfo() !== null) { - $international->appendChild( - $this->getCustomsInfo()->toXML($document, $prefix) - ); + if ($this->customsInfo !== null) { + $international->appendChild($this->customsInfo->toXML($document, $innerPrefix)); } - if ($this->getParcelContents()) { - $parcelContents = $document->createElement(XmlHelper::getPrefixedTagName('parcelContents', $prefix)); - foreach ($this->getParcelContents() as $parcelContent) { - $parcelContents->appendChild( - $parcelContent->toXML($document, $prefix) - ); + if (!empty($this->parcelContents)) { + $parcelContents = $document->createElement(XmlHelper::getPrefixedTagName('parcelContents', $innerPrefix)); + foreach ($this->parcelContents as $parcelContent) { + $parcelContents->appendChild($parcelContent->toXML($document, $innerPrefix)); } $international->appendChild($parcelContents); } @@ -276,25 +195,19 @@ public function toXML(DOMDocument $document, $prefix = null) } /** - * @param SimpleXMLElement $xml - * - * @return International - * * @throws BpostInvalidLengthException * @throws BpostInvalidValueException * @throws BpostNotImplementedException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): International { - $international = new International(); + $international = new self(); - if (isset($xml->international->product) && $xml->international->product != '') { - $international->setProduct( - (string) $xml->international->product - ); + if (isset($xml->international->product) && (string)$xml->international->product !== '') { + $international->setProduct((string)$xml->international->product); } + if (isset($xml->international->options)) { - /** @var SimpleXMLElement $optionData */ $options = $xml->international->options->children('http://schema.post.be/shm/deepintegration/v3/common'); foreach ($options as $optionData) { switch ($optionData->getName()) { @@ -305,44 +218,34 @@ public static function createFromXML(SimpleXMLElement $xml) $option = Messaging::createFromXML($optionData); break; default: - $className = '\Bpost\BpostApiClient\Bpost\Order\Box\Option\\' . ucfirst($optionData->getName()); + $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName()); XmlHelper::assertMethodCreateFromXmlExists($className); - $option = call_user_func( - array($className, 'createFromXML'), - $optionData - ); + $option = $className::createFromXML($optionData); } - $international->addOption($option); } } - if (isset($xml->international->parcelWeight) && $xml->international->parcelWeight != '') { - $international->setParcelWeight( - (int) $xml->international->parcelWeight - ); + + if (isset($xml->international->parcelWeight) && (string)$xml->international->parcelWeight !== '') { + $international->setParcelWeight((int)$xml->international->parcelWeight); } + if (isset($xml->international->receiver)) { - $receiverData = $xml->international->receiver->children( - 'http://schema.post.be/shm/deepintegration/v3/common' - ); - $international->setReceiver( - Receiver::createFromXML($receiverData) - ); + $receiverData = $xml->international->receiver->children('http://schema.post.be/shm/deepintegration/v3/common'); + $international->setReceiver(Receiver::createFromXML($receiverData)); } + if (isset($xml->international->customsInfo)) { - $international->setCustomsInfo( - CustomsInfo::createFromXML($xml->international->customsInfo) - ); + $international->setCustomsInfo(CustomsInfo::createFromXML($xml->international->customsInfo)); } + if (isset($xml->international->parcelContents)) { - /** @var SimpleXMLElement $optionData */ $parcelContents = $xml->international->parcelContents->children('international', true); foreach ($parcelContents as $parcelContentXml) { - $parcelContent = ParcelContent::createFromXML($parcelContentXml); - $international->addParcelContent($parcelContent); + $international->addParcelContent(ParcelContent::createFromXML($parcelContentXml)); } } return $international; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/International/ParcelContent.php b/src/Bpost/Order/Box/International/ParcelContent.php index e51252d6..5c675c13 100644 --- a/src/Bpost/Order/Box/International/ParcelContent.php +++ b/src/Bpost/Order/Box/International/ParcelContent.php @@ -1,4 +1,5 @@ numberOfItemType; } - /** - * @param int $numberOfItemType - * - * @return self - */ - public function setNumberOfItemType($numberOfItemType) + public function setNumberOfItemType(?int $numberOfItemType): void { $this->numberOfItemType = $numberOfItemType; - - return $this; } - /** - * @return string - */ - public function getValueOfItem() + public function getValueOfItem(): ?int { return $this->valueOfItem; } - /** - * @param string $valueOfItem - * - * @return self - */ - public function setValueOfItem($valueOfItem) + public function setValueOfItem(?int $valueOfItem): void { $this->valueOfItem = $valueOfItem; - - return $this; } - /** - * @return string - */ - public function getItemDescription() + public function getItemDescription(): ?string { return $this->itemDescription; } - /** - * @param string $itemDescription - * - * @return self - */ - public function setItemDescription($itemDescription) + public function setItemDescription(?string $itemDescription): void { if (strlen($itemDescription) > 30) { $itemDescription = substr($itemDescription, 0, 30); } $this->itemDescription = $itemDescription; - - return $this; } - /** - * @return int - */ - public function getNettoWeight() + public function getNettoWeight(): ?int { return $this->nettoWeight; } - /** - * @param int $nettoWeight - * - * @return self - */ - public function setNettoWeight($nettoWeight) + public function setNettoWeight(?int $nettoWeight): void { $this->nettoWeight = $nettoWeight; - - return $this; } - /** - * @return string - */ - public function getHsTariffCode() + public function getHsTariffCode(): ?string { return $this->hsTariffCode; } - /** - * @param string $hsTariffCode - * - * @return self - */ - public function setHsTariffCode($hsTariffCode) + public function setHsTariffCode(?string $hsTariffCode): void { $this->hsTariffCode = $hsTariffCode; - - return $this; } - /** - * @return string - */ - public function getOriginOfGoods() + public function getOriginOfGoods(): ?string { return $this->originOfGoods; } - /** - * @param string $originOfGoods - * - * @return self - */ - public function setOriginOfGoods($originOfGoods) + public function setOriginOfGoods(?string $originOfGoods): void { $this->originOfGoods = $originOfGoods; - - return $this; } /** - * @param DOMDocument $document - * @param string|null $prefix - * - * @return DOMElement|false - * * @throws DOMException */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement { $parcelContent = $document->createElement(XmlHelper::getPrefixedTagName('parcelContent', $prefix)); $parcelContent->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('numberOfItemType', $prefix), - $this->getNumberOfItemType() + (string) $this->getNumberOfItemType() ) ); $parcelContent->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('valueOfItem', $prefix), - $this->getValueOfItem() + (string) $this->getValueOfItem() ) ); $parcelContent->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('itemDescription', $prefix), - $this->getItemDescription() + (string) $this->getItemDescription() ) ); $parcelContent->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('nettoWeight', $prefix), - $this->getNettoWeight() + (string) $this->getNettoWeight() ) ); $parcelContent->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('hsTariffCode', $prefix), - $this->getHsTariffCode() + (string) $this->getHsTariffCode() ) ); $parcelContent->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('originOfGoods', $prefix), - $this->getOriginOfGoods() + (string) $this->getOriginOfGoods() ) ); return $parcelContent; } - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - $parcelContent = new ParcelContent(); + $parcelContent = new self(); - if (isset($xml->numberOfItemType) && $xml->numberOfItemType != '') { - $parcelContent->setNumberOfItemType( - (int) $xml->numberOfItemType - ); + if (isset($xml->numberOfItemType) && (string)$xml->numberOfItemType !== '') { + $parcelContent->setNumberOfItemType((int)$xml->numberOfItemType); } - if (isset($xml->valueOfItem) && $xml->valueOfItem != '') { - $parcelContent->setValueOfItem( - (int) $xml->valueOfItem - ); + if (isset($xml->valueOfItem) && (string)$xml->valueOfItem !== '') { + // XML porte des cents → int + $parcelContent->setValueOfItem((int)$xml->valueOfItem); } - if (isset($xml->itemDescription) && $xml->itemDescription != '') { - $parcelContent->setItemDescription( - (string) $xml->itemDescription - ); + if (isset($xml->itemDescription) && (string)$xml->itemDescription !== '') { + $parcelContent->setItemDescription((string)$xml->itemDescription); } - if (isset($xml->nettoWeight) && $xml->nettoWeight != '') { - $parcelContent->setNettoWeight( - (int) $xml->nettoWeight - ); + if (isset($xml->nettoWeight) && (string)$xml->nettoWeight !== '') { + $parcelContent->setNettoWeight((int)$xml->nettoWeight); } - if (isset($xml->hsTariffCode) && $xml->hsTariffCode != '') { - $parcelContent->setHsTariffCode( - (int) $xml->hsTariffCode - ); + if (isset($xml->hsTariffCode) && (string)$xml->hsTariffCode !== '') { + // FIX: garder en string (pas (int)) + $parcelContent->setHsTariffCode((string)$xml->hsTariffCode); } - if (isset($xml->originOfGoods) && $xml->originOfGoods != '') { - $parcelContent->setOriginOfGoods( - (string) $xml->originOfGoods - ); + if (isset($xml->originOfGoods) && (string)$xml->originOfGoods !== '') { + $parcelContent->setOriginOfGoods((string)$xml->originOfGoods); } return $parcelContent; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/National.php b/src/Bpost/Order/Box/National.php index 60101012..ed12293a 100644 --- a/src/Bpost/Order/Box/National.php +++ b/src/Bpost/Order/Box/National.php @@ -1,4 +1,5 @@ options = $options; } - /** - * @return Option[] - */ - public function getOptions() + public function getOptions(): array { return $this->options; } - /** - * @param Option $option - */ - public function addOption(Option $option) + public function addOption(Option $option): void { $this->options[] = $option; } - /** - * @param string $product - */ - public function setProduct($product) + public function setProduct(string $product): void { $this->product = $product; } - /** - * @return string - */ - public function getProduct() + public function getProduct(): ?string { return $this->product; } /** * @remark should be implemented by the child class - * - * @return array */ - public static function getPossibleProductValues() + public static function getPossibleProductValues(): array { - return array(); + return []; } - /** - * @param int $weight - */ - public function setWeight($weight) + public function setWeight(int $weight): void { $this->weight = $weight; } - /** - * @return int - */ - public function getWeight() + public function getWeight(): ?int { return $this->weight; } - /** - * @param Day[] $openingHours - */ - public function setOpeningHours(array $openingHours) + public function setOpeningHours(array $openingHours): void { $this->openingHours = $openingHours; } - /** - * @param Day $day - */ - public function addOpeningHour(Day $day) + public function addOpeningHour(Day $day): void { $this->openingHours[] = $day; } - /** - * @return Day[] - */ - public function getOpeningHours() + public function getOpeningHours(): array { return $this->openingHours; } - /** - * @param string $desiredDeliveryPlace - */ - public function setDesiredDeliveryPlace($desiredDeliveryPlace) + public function setDesiredDeliveryPlace(?string $desiredDeliveryPlace): void { $this->desiredDeliveryPlace = $desiredDeliveryPlace; } - /** - * @return string - */ - public function getDesiredDeliveryPlace() + public function getDesiredDeliveryPlace(): ?string { return $this->desiredDeliveryPlace; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * @param string $type - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = null, $type = null) + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { - $typeElement = $document->createElement($type); + $typeElement = $document->createElement((string)$type); - if ($this->getProduct() !== null) { + if ($this->product !== null) { $typeElement->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('product', $prefix), - $this->getProduct() - ) + $document->createElement(XmlHelper::getPrefixedTagName('product', $prefix), $this->product) ); } - $options = $this->getOptions(); - if (!empty($options)) { + if (!empty($this->options)) { $optionsElement = $document->createElement('options'); - foreach ($options as $option) { - $optionsElement->appendChild( - $option->toXML($document) - ); + foreach ($this->options as $option) { + $optionsElement->appendChild($option->toXML($document)); } $typeElement->appendChild($optionsElement); } - if ($this->getWeight() !== null) { + if ($this->weight !== null) { $typeElement->appendChild( - $document->createElement(XmlHelper::getPrefixedTagName('weight', $prefix), $this->getWeight()) + $document->createElement(XmlHelper::getPrefixedTagName('weight', $prefix), (string)$this->weight) ); } - $openingHours = $this->getOpeningHours(); - if (!empty($openingHours)) { + if (!empty($this->openingHours)) { $openingHoursElement = $document->createElement('openingHours'); - /** @var Day $day */ - foreach ($openingHours as $day) { - $openingHoursElement->appendChild( - $day->toXML($document) - ); + foreach ($this->openingHours as $day) { + $openingHoursElement->appendChild($day->toXML($document)); } $typeElement->appendChild($openingHoursElement); } - if ($this->getDesiredDeliveryPlace() !== null) { + if ($this->desiredDeliveryPlace !== null) { $typeElement->appendChild( $document->createElement( XmlHelper::getPrefixedTagName('desiredDeliveryPlace', $prefix), - $this->getDesiredDeliveryPlace() + $this->desiredDeliveryPlace ) ); } @@ -211,38 +157,35 @@ public function toXML(DOMDocument $document, $prefix = null, $type = null) } /** - * @param SimpleXMLElement $nationalXml - * @param National $self - * - * @return AtHome - * + * @throws BpostInvalidLengthException + * @throws BpostNotImplementedException + * @throws BpostInvalidValueException * @throws BpostException - * @throws BpostXmlInvalidItemException */ - public static function createFromXML(SimpleXMLElement $nationalXml, National $self = null) + public static function createFromXML(SimpleXMLElement $xml, National $self = null): National { if ($self === null) { throw new BpostException('Set an instance of National'); } - if (isset($nationalXml->product) && $nationalXml->product != '') { - $self->setProduct( - (string) $nationalXml->product - ); + if (isset($nationalXml->product) && (string)$nationalXml->product !== '') { + $self->setProduct((string)$nationalXml->product); } if (isset($nationalXml->options) && !empty($nationalXml->options)) { - /** @var SimpleXMLElement $optionData */ foreach ($nationalXml->options as $optionData) { $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common'); - if (in_array($optionData->getName(), array( + if (in_array( + $optionData->getName(), + [ Messaging::MESSAGING_TYPE_INFO_DISTRIBUTED, Messaging::MESSAGING_TYPE_INFO_NEXT_DAY, Messaging::MESSAGING_TYPE_INFO_REMINDER, Messaging::MESSAGING_TYPE_KEEP_ME_INFORMED, - )) - ) { + ], + true + )) { $option = Messaging::createFromXML($optionData); } else { $option = self::getOptionFromOptionData($optionData); @@ -252,42 +195,33 @@ public static function createFromXML(SimpleXMLElement $nationalXml, National $se } } - if (isset($nationalXml->weight) && $nationalXml->weight != '') { - $self->setWeight( - (int) $nationalXml->weight - ); + if (isset($nationalXml->weight) && (string)$nationalXml->weight !== '') { + $self->setWeight((int)$nationalXml->weight); } - if (isset($nationalXml->openingHours) && $nationalXml->openingHours != '') { + if (isset($nationalXml->openingHours) && (string)$nationalXml->openingHours !== '') { foreach ($nationalXml->openingHours->children() as $day => $value) { - $self->addOpeningHour(new Day($day, (string) $value)); + $self->addOpeningHour(new Day((string)$day, (string)$value)); } } - if (isset($nationalXml->desiredDeliveryPlace) && $nationalXml->desiredDeliveryPlace != '') { - $self->setDesiredDeliveryPlace( - (string) $nationalXml->desiredDeliveryPlace - ); + if (isset($nationalXml->desiredDeliveryPlace) && (string)$nationalXml->desiredDeliveryPlace !== '') { + $self->setDesiredDeliveryPlace((string)$nationalXml->desiredDeliveryPlace); } return $self; } /** - * @param SimpleXMLElement $optionData - * - * @return Option - * * @throws BpostNotImplementedException */ - protected static function getOptionFromOptionData(SimpleXMLElement $optionData) + protected static function getOptionFromOptionData(SimpleXMLElement $optionData): Option { $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName()); XmlHelper::assertMethodCreateFromXmlExists($className); - return call_user_func( - array($className, 'createFromXML'), - $optionData - ); + /** @var callable $factory */ + $factory = [$className, 'createFromXML']; + return $factory($optionData); } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php b/src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php index 2c4ff049..8789342f 100644 --- a/src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php +++ b/src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php @@ -1,4 +1,5 @@ createElement($tagName); - - return $xml; + return $document->createElement($tagName); } /** * @todo Implement it, because today, nothing is specified - * - * @param SimpleXMLElement $xml - * * @return ParcelLockerReducedMobilityZone|ComplexAttribute */ - public static function createFromXml(SimpleXMLElement $xml) + public static function createFromXml(SimpleXMLElement $xml): self { - $self = new self(); - - return $self; + return new self(); } } diff --git a/src/Bpost/Order/Box/National/ShopHandlingInstruction.php b/src/Bpost/Order/Box/National/ShopHandlingInstruction.php index c3a87797..89909436 100644 --- a/src/Bpost/Order/Box/National/ShopHandlingInstruction.php +++ b/src/Bpost/Order/Box/National/ShopHandlingInstruction.php @@ -1,4 +1,5 @@ validateLength(50); } - /** - * @return string - */ - protected function getDefaultKey() + protected function getDefaultKey(): string { return 'shopHandlingInstruction'; } diff --git a/src/Bpost/Order/Box/National/Unregistered.php b/src/Bpost/Order/Box/National/Unregistered.php index 59c3e17a..58e69cc0 100644 --- a/src/Bpost/Order/Box/National/Unregistered.php +++ b/src/Bpost/Order/Box/National/Unregistered.php @@ -1,4 +1,5 @@ language !== null; } - /** - * @return string - */ - public function getLanguage() + public function getLanguage(): ?string { - return $this->hasLanguage() ? $this->language->getValue() : null; + return $this->language?->getValue(); } - /** - * @param string $language - */ - public function setLanguage($language) + public function setLanguage(?string $language): void { - $this->language = new Language($language); + $this->language = $language !== null ? new Language($language) : null; } - /** - * @return bool - */ - public function hasMobilePhone() + public function hasMobilePhone(): bool { return $this->mobilePhone !== null; } - /** - * @return string - */ - public function getMobilePhone() + public function getMobilePhone(): ?string { - return $this->hasMobilePhone() ? $this->mobilePhone->getValue() : null; + return $this->mobilePhone?->getValue(); } - /** - * @param string $mobilePhone - */ - public function setMobilePhone($mobilePhone) + public function setMobilePhone(?string $mobilePhone): void { - $this->mobilePhone = new PhoneNumber($mobilePhone); + $this->mobilePhone = $mobilePhone !== null ? new PhoneNumber($mobilePhone) : null; } - /** - * @return bool - */ - public function hasEmailAddress() + public function hasEmailAddress(): bool { return $this->emailAddress !== null; } - /** - * @return string - */ - public function getEmailAddress() + public function getEmailAddress(): ?string { - return $this->hasEmailAddress() ? $this->emailAddress->getValue() : null; + return $this->emailAddress?->getValue(); } - /** - * @param string $emailAddress - */ - public function setEmailAddress($emailAddress) + public function setEmailAddress(?string $emailAddress): void { - $this->emailAddress = new EmailAddressCharacteristic($emailAddress); + $this->emailAddress = $emailAddress !== null ? new EmailAddressCharacteristic($emailAddress) : null; } - /** - * @return bool - */ - public function hasParcelLockerReducedMobilityZone() + public function hasParcelLockerReducedMobilityZone(): bool { return $this->parcelLockerReducedMobilityZone !== null; } - /** - * @return ParcelLockerReducedMobilityZone - */ - public function getParcelLockerReducedMobilityZone() + public function getParcelLockerReducedMobilityZone(): ?ParcelLockerReducedMobilityZone { return $this->parcelLockerReducedMobilityZone; } - /** - * @param ParcelLockerReducedMobilityZone $parcelLockerReducedMobilityZone - */ - public function setParcelLockerReducedMobilityZone(ParcelLockerReducedMobilityZone $parcelLockerReducedMobilityZone) + public function setParcelLockerReducedMobilityZone(?ParcelLockerReducedMobilityZone $zone): void { - $this->parcelLockerReducedMobilityZone = $parcelLockerReducedMobilityZone; + $this->parcelLockerReducedMobilityZone = $zone; } /** - * @param DOMDocument $document - * @param string $prefix - * @param string $type - * - * @return DOMElement + * @throws \DOMException */ - public function toXml(DOMDocument $document, $prefix = null, $type = null) + public function toXml(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement { $tagName = XmlHelper::getPrefixedTagName('unregistered', $prefix); - $xml = $document->createElement($tagName); if ($this->hasLanguage()) { - $tagName = XmlHelper::getPrefixedTagName('language', $prefix); - $xml->appendChild($document->createElement($tagName, $this->getLanguage())); + $xml->appendChild( + $document->createElement( + XmlHelper::getPrefixedTagName('language', $prefix), + (string)$this->getLanguage() + ) + ); } - if ($this->getMobilePhone() !== null) { - $tagName = XmlHelper::getPrefixedTagName('mobilePhone', $prefix); - $xml->appendChild($document->createElement($tagName, $this->getMobilePhone())); + if (($mobile = $this->getMobilePhone()) !== null) { + $xml->appendChild( + $document->createElement( + XmlHelper::getPrefixedTagName('mobilePhone', $prefix), + $mobile + ) + ); } - if ($this->getEmailAddress() !== null) { - $tagName = XmlHelper::getPrefixedTagName('emailAddress', $prefix); - $xml->appendChild($document->createElement($tagName, $this->getEmailAddress())); + if (($email = $this->getEmailAddress()) !== null) { + $xml->appendChild( + $document->createElement( + XmlHelper::getPrefixedTagName('emailAddress', $prefix), + $email + ) + ); } if ($this->hasParcelLockerReducedMobilityZone()) { + // Attention: notre classe ParcLocker... expose bien toXml(), pas toXML() $xml->appendChild( - $this->getParcelLockerReducedMobilityZone()->toXML($document, $prefix, $type) + $this->parcelLockerReducedMobilityZone->toXml($document, $prefix, $type) ); } return $xml; } - /** - * @param SimpleXMLElement $xml - * - * @return Unregistered - */ - public static function createFromXml(SimpleXMLElement $xml) + public static function createFromXml(SimpleXMLElement $xml): self { $self = new self(); - if (isset($xml->language) && $xml->language != '') { - $self->setLanguage((string) $xml->language); + if (isset($xml->language) && (string)$xml->language !== '') { + $self->setLanguage((string)$xml->language); } - if (isset($xml->mobilePhone) && $xml->mobilePhone != '') { - $self->setMobilePhone((string) $xml->mobilePhone); + if (isset($xml->mobilePhone) && (string)$xml->mobilePhone !== '') { + $self->setMobilePhone((string)$xml->mobilePhone); } - if (isset($xml->emailAddress) && $xml->emailAddress != '') { - $self->setEmailAddress((string) $xml->emailAddress); + if (isset($xml->emailAddress) && (string)$xml->emailAddress !== '') { + $self->setEmailAddress((string)$xml->emailAddress); } if (isset($xml->parcelLockerReducedMobilityZone)) { $self->setParcelLockerReducedMobilityZone( - parcelLockerReducedMobilityZone::createFromXml($xml->parcelLockerReducedMobilityZone) + ParcelLockerReducedMobilityZone::createFromXml($xml->parcelLockerReducedMobilityZone) ); } return $self; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/OpeningHour/Day.php b/src/Bpost/Order/Box/OpeningHour/Day.php index 87376cc4..45503d84 100644 --- a/src/Bpost/Order/Box/OpeningHour/Day.php +++ b/src/Bpost/Order/Box/OpeningHour/Day.php @@ -1,11 +1,12 @@ setDay($day); + $this->setValue($value); + } /** - * @param string $day - * * @throws BpostInvalidValueException */ - public function setDay($day) + public function setDay(string $day): void { - if (!in_array($day, self::getPossibleDayValues())) { + if (!in_array($day, self::getPossibleDayValues(), true)) { throw new BpostInvalidValueException('day', $day, self::getPossibleDayValues()); } - $this->day = $day; } - /** - * @return string - */ - public function getDay() + public function getDay(): string { return $this->day; } - /** - * @return array - */ - public static function getPossibleDayValues() + public static function getPossibleDayValues(): array { - return array( + return [ self::DAY_MONDAY, self::DAY_TUESDAY, self::DAY_WEDNESDAY, @@ -72,50 +66,27 @@ public static function getPossibleDayValues() self::DAY_FRIDAY, self::DAY_SATURDAY, self::DAY_SUNDAY, - ); + ]; } - /** - * @param string $value - */ - public function setValue($value) + public function setValue(string $value): void { $this->value = $value; } - /** - * @return string - */ - public function getValue() + public function getValue(): string { return $this->value; } /** - * @param string $day - * @param string $value - * - * @throws BpostInvalidValueException - */ - public function __construct($day, $value) - { - $this->setDay($day); - $this->setValue($value); - } - - /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement { return $document->createElement( XmlHelper::getPrefixedTagName($this->getDay(), $prefix), $this->getValue() ); } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php b/src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php index 86e7ff6a..c3507772 100644 --- a/src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php +++ b/src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php @@ -1,10 +1,11 @@ createElement(XmlHelper::getPrefixedTagName('automaticSecondPresentation', $prefix)); + return $document->createElement( + XmlHelper::getPrefixedTagName('automaticSecondPresentation', $prefix) + ); } - /** - * @param SimpleXMLElement $xml - * - * @return static - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): static { return new static(); } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/Option/CashOnDelivery.php b/src/Bpost/Order/Box/Option/CashOnDelivery.php index f9c930b9..510e837e 100644 --- a/src/Bpost/Order/Box/Option/CashOnDelivery.php +++ b/src/Bpost/Order/Box/Option/CashOnDelivery.php @@ -1,10 +1,11 @@ setAmount($amount); + $this->setIban($iban); + $this->setBic($bic); + } - /** - * @param float $amount - */ - public function setAmount($amount) + public function setAmount(float $amount): void { $this->amount = $amount; } - /** - * @return float - */ - public function getAmount() + public function getAmount(): float { return $this->amount; } - /** - * @param string $bic - */ - public function setBic($bic) + public function setBic(string $bic): void { $this->bic = $bic; } - /** - * @return string - */ - public function getBic() + public function getBic(): string { return $this->bic; } - /** - * @param string $iban - */ - public function setIban($iban) + public function setIban(string $iban): void { $this->iban = $iban; } - /** - * @return string - */ - public function getIban() + public function getIban(): string { return $this->iban; } /** - * @param float $amount - * @param string $iban - * @param string $bic + * @throws \DOMException */ - public function __construct($amount, $iban, $bic) - { - $this->setAmount($amount); - $this->setIban($iban); - $this->setBic($bic); - } - - /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement - */ - public function toXML(DOMDocument $document, $prefix = 'common') + public function toXML(DOMDocument $document, ?string $prefix = 'common'): DOMElement { $cod = $document->createElement(XmlHelper::getPrefixedTagName('cod', $prefix)); - if ($this->getAmount() !== null) { - $cod->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('codAmount', $prefix), - $this->getAmount() - ) - ); - } - if ($this->getIban() !== null) { - $cod->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('iban', $prefix), - $this->getIban() - ) - ); - } - if ($this->getBic() !== null) { - $cod->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('bic', $prefix), - $this->getBic() - ) - ); - } + // Montant formaté en 2 décimales (ex: 10 => "10.00") + $cod->appendChild( + $document->createElement( + XmlHelper::getPrefixedTagName('codAmount', $prefix), + sprintf('%.2f', $this->getAmount()) + ) + ); + + $cod->appendChild( + $document->createElement( + XmlHelper::getPrefixedTagName('iban', $prefix), + $this->getIban() + ) + ); + + $cod->appendChild( + $document->createElement( + XmlHelper::getPrefixedTagName('bic', $prefix), + $this->getBic() + ) + ); return $cod; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/Option/Insurance.php b/src/Bpost/Order/Box/Option/Insurance.php deleted file mode 100644 index ed00611a..00000000 --- a/src/Bpost/Order/Box/Option/Insurance.php +++ /dev/null @@ -1,11 +0,0 @@ -setType($type); + if ($value !== null) { + $this->setValue($value); + } + } - /** - * @return array - */ - public static function getPossibleTypeValues() + public static function getPossibleTypeValues(): array { - return array( + return [ self::INSURANCE_TYPE_BASIC_INSURANCE, self::INSURANCE_TYPE_ADDITIONAL_INSURANCE, - ); + ]; } /** - * @param string $type - * * @throws BpostInvalidValueException */ - public function setType($type) + public function setType(string $type): void { - if (!in_array($type, self::getPossibleTypeValues())) { + if (!in_array($type, self::getPossibleTypeValues(), true)) { throw new BpostInvalidValueException('type', $type, self::getPossibleTypeValues()); } - $this->type = $type; } - /** - * @return string - */ - public function getType() + public function getType(): string { return $this->type; } - /** - * @param string $value - * - * @throws BpostInvalidValueException - */ - public function setValue($value) - { - if (!in_array($value, self::getPossibleValueValues())) { - throw new BpostInvalidValueException('value', $value, self::getPossibleValueValues()); - } - - $this->value = $value; - } - - /** - * @return string - */ - public function getValue() - { - return $this->value; - } - - /** - * @return array - */ - public static function getPossibleValueValues() + public static function getPossibleValueValues(): array { - return array( + return [ self::INSURANCE_AMOUNT_UP_TO_2500_EUROS, self::INSURANCE_AMOUNT_UP_TO_5000_EUROS, self::INSURANCE_AMOUNT_UP_TO_7500_EUROS, @@ -116,34 +87,30 @@ public static function getPossibleValueValues() self::INSURANCE_AMOUNT_UP_TO_20000_EUROS, self::INSURANCE_AMOUNT_UP_TO_22500_EUROS, self::INSURANCE_AMOUNT_UP_TO_25000_EUROS, - ); + ]; } /** - * @param string $type - * @param string|null $value - * * @throws BpostInvalidValueException */ - public function __construct($type, $value = null) + public function setValue(int $value): void { - $this->setType($type); - if ($value !== null) { - $this->setValue($value); + if (!in_array($value, self::getPossibleValueValues(), true)) { + throw new BpostInvalidValueException('value', (string)$value, self::getPossibleValueValues()); } + $this->value = $value; + } + + public function getValue(): ?int + { + return $this->value; } + /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement - * * @throws DOMException */ - public function toXML(DOMDocument $document, $prefix = 'common') + public function toXML(DOMDocument $document, ?string $prefix = 'common'): DOMElement { $insured = $document->createElement(XmlHelper::getPrefixedTagName('insured', $prefix)); @@ -151,26 +118,23 @@ public function toXML(DOMDocument $document, $prefix = 'common') $insured->appendChild($insurance); if ($this->getValue() !== null) { - $insurance->setAttribute('value', $this->getValue()); + $insurance->setAttribute('value', (string)$this->getValue()); } return $insured; } /** - * @param SimpleXMLElement $xml - * - * @return static - * * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): static { $insuranceDetail = $xml->children('http://schema.post.be/shm/deepintegration/v3/common'); - $type = $insuranceDetail->getName(); - $value = $insuranceDetail->attributes()->value !== null ? (int) $insuranceDetail->attributes()->value : null; + $valueAttr = $insuranceDetail->attributes()->value ?? null; + $value = $valueAttr !== null ? (int)$valueAttr : null; + // Compat héritée : additionalInsurance avec value=1 => basicInsurance sans value if ($type === static::INSURANCE_TYPE_ADDITIONAL_INSURANCE && $value === 1) { $type = static::INSURANCE_TYPE_BASIC_INSURANCE; $value = null; @@ -178,4 +142,4 @@ public static function createFromXML(SimpleXMLElement $xml) return new static($type, $value); } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/Option/Messaging.php b/src/Bpost/Order/Box/Option/Messaging.php index aa53e3b7..0ef3ed4e 100644 --- a/src/Bpost/Order/Box/Option/Messaging.php +++ b/src/Bpost/Order/Box/Option/Messaging.php @@ -1,12 +1,13 @@ setType($type); + $this->setLanguage($language); - /** - * @var string - */ - private $emailAddress; + if ($emailAddress !== null) { + $this->setEmailAddress($emailAddress); + } + if ($mobilePhone !== null) { + $this->setMobilePhone($mobilePhone); + } + } - /** - * @var string - */ - private $mobilePhone; + public static function getPossibleLanguageValues(): array + { + return [ + self::MESSAGING_LANGUAGE_EN, + self::MESSAGING_LANGUAGE_NL, + self::MESSAGING_LANGUAGE_FR, + self::MESSAGING_LANGUAGE_DE, + ]; + } + + public static function getPossibleTypeValues(): array + { + return [ + self::MESSAGING_TYPE_INFO_DISTRIBUTED, + self::MESSAGING_TYPE_INFO_NEXT_DAY, + self::MESSAGING_TYPE_INFO_REMINDER, + self::MESSAGING_TYPE_KEEP_ME_INFORMED, + ]; + } /** - * @param string $emailAddress - * - * @throws BpostInvalidLengthException + * @throws BpostInvalidValueException */ - public function setEmailAddress($emailAddress) + public function setType(string $type): void { - $length = 50; - if (mb_strlen($emailAddress) > $length) { - throw new BpostInvalidLengthException('emailAddress', mb_strlen($emailAddress), $length); + if (!in_array($type, self::getPossibleTypeValues(), true)) { + throw new BpostInvalidValueException('type', $type, self::getPossibleTypeValues()); } - - $this->emailAddress = $emailAddress; + $this->type = $type; } - /** - * @return string - */ - public function getEmailAddress() + public function getType(): string { - return $this->emailAddress; + return $this->type; } /** - * @param string $language - * * @throws BpostInvalidValueException */ - public function setLanguage($language) + public function setLanguage(string $language): void { $language = strtoupper($language); - - if (!in_array($language, self::getPossibleLanguageValues())) { + if (!in_array($language, self::getPossibleLanguageValues(), true)) { throw new BpostInvalidValueException('language', $language, self::getPossibleLanguageValues()); } - $this->language = $language; } - /** - * @return string - */ - public function getLanguage() + public function getLanguage(): string { return $this->language; } /** - * @return array + * @throws BpostInvalidLengthException */ - public static function getPossibleLanguageValues() + public function setEmailAddress(string $emailAddress): void { - return array( - self::MESSAGING_LANGUAGE_EN, - self::MESSAGING_LANGUAGE_NL, - self::MESSAGING_LANGUAGE_FR, - self::MESSAGING_LANGUAGE_DE, - ); + $length = 50; + if (mb_strlen($emailAddress) > $length) { + throw new BpostInvalidLengthException('emailAddress', mb_strlen($emailAddress), $length); + } + $this->emailAddress = $emailAddress; + } + + public function getEmailAddress(): ?string + { + return $this->emailAddress; } /** - * @param string $mobilePhone - * * @throws BpostInvalidLengthException */ - public function setMobilePhone($mobilePhone) + public function setMobilePhone(string $mobilePhone): void { $length = 20; if (mb_strlen($mobilePhone) > $length) { throw new BpostInvalidLengthException('mobilePhone', mb_strlen($mobilePhone), $length); } - $this->mobilePhone = $mobilePhone; } - /** - * @return string - */ - public function getMobilePhone() + public function getMobilePhone(): ?string { return $this->mobilePhone; } /** - * @return array - */ - public static function getPossibleTypeValues() - { - return array( - self::MESSAGING_TYPE_INFO_DISTRIBUTED, - self::MESSAGING_TYPE_INFO_NEXT_DAY, - self::MESSAGING_TYPE_INFO_REMINDER, - self::MESSAGING_TYPE_KEEP_ME_INFORMED, - ); - } - - /** - * @param string $type - * - * @throws BpostInvalidValueException - */ - public function setType($type) - { - if (!in_array($type, self::getPossibleTypeValues())) { - throw new BpostInvalidValueException('type', $type, self::getPossibleTypeValues()); - } - - $this->type = $type; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $type - * @param string $language - * @param string|null $emailAddress - * @param string|null $mobilePhone - * - * @throws BpostInvalidLengthException - * @throws BpostInvalidValueException - */ - public function __construct($type, $language, $emailAddress = null, $mobilePhone = null) - { - $this->setType($type); - $this->setLanguage($language); - - if ($emailAddress !== null) { - $this->setEmailAddress($emailAddress); - } - if ($mobilePhone !== null) { - $this->setMobilePhone($mobilePhone); - } - } - - /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = 'common') + public function toXML(DOMDocument $document, ?string $prefix = 'common'): DOMElement { $messaging = $document->createElement(XmlHelper::getPrefixedTagName($this->getType(), $prefix)); $messaging->setAttribute('language', $this->getLanguage()); - if ($this->getEmailAddress() !== null) { + if ($this->emailAddress !== null) { $messaging->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('emailAddress', $prefix), - $this->getEmailAddress() - ) + $document->createElement(XmlHelper::getPrefixedTagName('emailAddress', $prefix), $this->emailAddress) ); } - if ($this->getMobilePhone() !== null) { + if ($this->mobilePhone !== null) { $messaging->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('mobilePhone', $prefix), - $this->getMobilePhone() - ) + $document->createElement(XmlHelper::getPrefixedTagName('mobilePhone', $prefix), $this->mobilePhone) ); } @@ -225,24 +164,20 @@ public function toXML(DOMDocument $document, $prefix = 'common') } /** - * @param SimpleXMLElement $xml - * - * @return Messaging - * * @throws BpostInvalidLengthException * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): static { - $messaging = new Messaging($xml->getName(), (string) $xml->attributes()->language); + $messaging = new static($xml->getName(), (string)$xml->attributes()->language); - if ((string) $xml->emailAddress !== '') { - $messaging->setEmailAddress((string) $xml->emailAddress); + if ((string)$xml->emailAddress !== '') { + $messaging->setEmailAddress((string)$xml->emailAddress); } - if ((string) $xml->mobilePhone !== '') { - $messaging->setMobilePhone((string) $xml->mobilePhone); + if ((string)$xml->mobilePhone !== '') { + $messaging->setMobilePhone((string)$xml->mobilePhone); } return $messaging; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/Option/Option.php b/src/Bpost/Order/Box/Option/Option.php index cdad5e73..53b05dee 100644 --- a/src/Bpost/Order/Box/Option/Option.php +++ b/src/Bpost/Order/Box/Option/Option.php @@ -1,4 +1,5 @@ createElement(XmlHelper::getPrefixedTagName('saturdayDelivery', $prefix)); } diff --git a/src/Bpost/Order/Box/Option/Signature.php b/src/Bpost/Order/Box/Option/Signature.php deleted file mode 100644 index 4e28836b..00000000 --- a/src/Bpost/Order/Box/Option/Signature.php +++ /dev/null @@ -1,11 +0,0 @@ -createElement(XmlHelper::getPrefixedTagName('signed', $prefix)); } - /** - * @param SimpleXMLElement $xml - * - * @return static - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): static { return new static(); } diff --git a/src/Bpost/Order/Customer.php b/src/Bpost/Order/Customer.php index e4ca3288..d9ab48f0 100644 --- a/src/Bpost/Order/Customer.php +++ b/src/Bpost/Order/Customer.php @@ -1,11 +1,12 @@ address = $address; } - /** - * @return \Bpost\BpostApiClient\Bpost\Order\Address - */ - public function getAddress() + public function getAddress(): ?Address { return $this->address; } - /** - * @param string $company - */ - public function setCompany($company) + public function setCompany(string $company): void { $this->company = $company; } - /** - * @return string - */ - public function getCompany() + public function getCompany(): ?string { return $this->company; } /** - * @param string $emailAddress - * * @throws BpostInvalidLengthException */ - public function setEmailAddress($emailAddress) + public function setEmailAddress(string $emailAddress): void { $length = 50; if (mb_strlen($emailAddress) > $length) { @@ -88,36 +56,25 @@ public function setEmailAddress($emailAddress) $this->emailAddress = $emailAddress; } - /** - * @return string - */ - public function getEmailAddress() + public function getEmailAddress(): ?string { return $this->emailAddress; } - /** - * @param string $name - */ - public function setName($name) + public function setName(string $name): void { $this->name = $name; } - /** - * @return string - */ - public function getName() + public function getName(): ?string { return $this->name; } /** - * @param string $phoneNumber - * * @throws BpostInvalidLengthException */ - public function setPhoneNumber($phoneNumber) + public function setPhoneNumber(string $phoneNumber): void { $length = 20; if (mb_strlen($phoneNumber) > $length) { @@ -126,94 +83,55 @@ public function setPhoneNumber($phoneNumber) $this->phoneNumber = $phoneNumber; } - /** - * @return string - */ - public function getPhoneNumber() + public function getPhoneNumber(): ?string { return $this->phoneNumber; } /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DomElement + * @throws \DOMException */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement { $customer = $document->createElement(XmlHelper::getPrefixedTagName(static::TAG_NAME, $prefix)); - if ($this->getName() !== null) { - $customer->appendChild( - $document->createElement( - 'common:name', - $this->getName() - ) - ); + if ($this->name !== null) { + $customer->appendChild($document->createElement('common:name', $this->name)); } - if ($this->getCompany() !== null) { - $customer->appendChild( - $document->createElement( - 'common:company', - $this->getCompany() - ) - ); + if ($this->company !== null) { + $customer->appendChild($document->createElement('common:company', $this->company)); } - if ($this->getAddress() !== null) { - $customer->appendChild( - $this->getAddress()->toXML($document) - ); + if ($this->address !== null) { + $customer->appendChild($this->address->toXML($document, 'common')); } - if ($this->getEmailAddress() !== null) { - $customer->appendChild( - $document->createElement( - 'common:emailAddress', - $this->getEmailAddress() - ) - ); + if ($this->emailAddress !== null) { + $customer->appendChild($document->createElement('common:emailAddress', $this->emailAddress)); } - if ($this->getPhoneNumber() !== null) { - $customer->appendChild( - $document->createElement( - 'common:phoneNumber', - $this->getPhoneNumber() - ) - ); + if ($this->phoneNumber !== null) { + $customer->appendChild($document->createElement('common:phoneNumber', $this->phoneNumber)); } return $customer; } /** - * @param SimpleXMLElement $xml - * @param Customer $instance - * - * @return Customer - * * @throws BpostInvalidLengthException */ - public static function createFromXMLHelper(SimpleXMLElement $xml, Customer $instance) + public static function createFromXMLHelper(SimpleXMLElement $xml, Customer $instance): Customer { - if (isset($xml->name) && $xml->name != '') { + if (isset($xml->name) && (string) $xml->name !== '') { $instance->setName((string) $xml->name); } - if (isset($xml->company) && $xml->company != '') { + if (isset($xml->company) && (string) $xml->company !== '') { $instance->setCompany((string) $xml->company); } if (isset($xml->address)) { - $instance->setAddress( - Address::createFromXML($xml->address) - ); + $instance->setAddress(Address::createFromXML($xml->address)); } - if (isset($xml->emailAddress) && $xml->emailAddress != '') { - $instance->setEmailAddress( - (string) $xml->emailAddress - ); + if (isset($xml->emailAddress) && (string) $xml->emailAddress !== '') { + $instance->setEmailAddress((string) $xml->emailAddress); } - if (isset($xml->phoneNumber) && $xml->phoneNumber != '') { + if (isset($xml->phoneNumber) && (string) $xml->phoneNumber !== '') { $instance->setPhoneNumber((string) $xml->phoneNumber); } diff --git a/src/Bpost/Order/Line.php b/src/Bpost/Order/Line.php index 9861f9c2..30adff1a 100644 --- a/src/Bpost/Order/Line.php +++ b/src/Bpost/Order/Line.php @@ -1,9 +1,10 @@ setText($text); + } + if ($numberOfItems !== null) { + $this->setNumberOfItems($numberOfItems); + } + } - /** - * @param int $nbOfItems - */ - public function setNumberOfItems($nbOfItems) + public function setNumberOfItems(int $nbOfItems): void { $this->numberOfItems = $nbOfItems; } - /** - * @return int - */ - public function getNumberOfItems() + public function getNumberOfItems(): ?int { return $this->numberOfItems; } - /** - * @param string $text - */ - public function setText($text) + public function setText(string $text): void { $this->text = $text; } - /** - * @return string - */ - public function getText() + public function getText(): ?string { return $this->text; } /** - * @param string $text - * @param int $numberOfItems + * @throws \DOMException */ - public function __construct($text = null, $numberOfItems = null) - { - if ($text != null) { - $this->setText($text); - } - if ($numberOfItems != null) { - $this->setNumberOfItems($numberOfItems); - } - } - - /** - * Return the object as an array for usage in the XML - * - * @param DomDocument $document - * @param string $prefix - * - * @return DOMElement - */ - public function toXML(DOMDocument $document, $prefix = null) + public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement { $line = $document->createElement(XmlHelper::getPrefixedTagName('orderLine', $prefix)); - if ($this->getText() !== null) { + if ($this->text !== null) { $line->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('text', $prefix), - $this->getText() - ) + $document->createElement(XmlHelper::getPrefixedTagName('text', $prefix), $this->text) ); } - if ($this->getNumberOfItems() !== null) { + if ($this->numberOfItems !== null) { $line->appendChild( - $document->createElement( - XmlHelper::getPrefixedTagName('nbOfItems', $prefix), - $this->getNumberOfItems() - ) + $document->createElement(XmlHelper::getPrefixedTagName('nbOfItems', $prefix), (string) $this->numberOfItems) ); } return $line; } - /** - * @param SimpleXMLElement $xml - * - * @return Line - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): Line { $line = new Line(); - if (isset($xml->text) && $xml->text !== '') { + + if (isset($xml->text) && (string) $xml->text !== '') { $line->setText((string) $xml->text); } - if (isset($xml->nbOfItems) && $xml->nbOfItems !== '') { + if (isset($xml->nbOfItems) && (string) $xml->nbOfItems !== '') { $line->setNumberOfItems((int) $xml->nbOfItems); } return $line; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/ParcelsDepotAddress.php b/src/Bpost/Order/ParcelsDepotAddress.php index 5009ebcc..1d5b4853 100644 --- a/src/Bpost/Order/ParcelsDepotAddress.php +++ b/src/Bpost/Order/ParcelsDepotAddress.php @@ -1,25 +1,12 @@ - */ class ParcelsDepotAddress extends Address { - const TAG_NAME = 'parcelsDepotAddress'; + public const TAG_NAME = 'parcelsDepotAddress'; - /** - * @param SimpleXMLElement $xml - * - * @return ParcelsDepotAddress - */ - public static function createFromXML(SimpleXMLElement $xml) - { - return parent::createFromXML($xml); - } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/PugoAddress.php b/src/Bpost/Order/PugoAddress.php index 31db9b82..7c61d64b 100644 --- a/src/Bpost/Order/PugoAddress.php +++ b/src/Bpost/Order/PugoAddress.php @@ -1,8 +1,11 @@ + $el = $document->createElement( + XmlHelper::getPrefixedTagName(self::TAG_NAME, 'national') + ); + + // Enfants en "common:*" + if ($this->getStreetName() !== null) { + $el->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('streetName', 'common'), + $this->getStreetName() + )); + } + if ($this->getNumber() !== null) { + $el->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('number', 'common'), + $this->getNumber() + )); + } + if ($this->getBox() !== null) { + $el->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('box', 'common'), + $this->getBox() + )); + } + if ($this->getPostalCode() !== null) { + $el->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('postalCode', 'common'), + $this->getPostalCode() + )); + } + if ($this->getLocality() !== null) { + $el->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('locality', 'common'), + $this->getLocality() + )); + } + if ($this->getCountryCode() !== null) { + $el->appendChild($document->createElement( + XmlHelper::getPrefixedTagName('countryCode', 'common'), + $this->getCountryCode() + )); + } + + return $el; } } diff --git a/src/Bpost/Order/Receiver.php b/src/Bpost/Order/Receiver.php index ae60a67f..dea70c7e 100644 --- a/src/Bpost/Order/Receiver.php +++ b/src/Bpost/Order/Receiver.php @@ -1,4 +1,5 @@ deliveryMethods; } - /** - * @param DeliveryMethod $deliveryMethod - */ - public function addDeliveryMethod(DeliveryMethod $deliveryMethod) + public function addDeliveryMethod(DeliveryMethod $deliveryMethod): void { $this->deliveryMethods[] = $deliveryMethod; } - /** - * @param SimpleXMLElement $xml - * - * @return ProductConfiguration - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { $productConfiguration = new self(); - $children = $xml->children(); - if (isset($children->deliveryMethod)) { - foreach ($children->deliveryMethod as $deliveryMethodXml) { - $productConfiguration->addDeliveryMethod(DeliveryMethod::createFromXML($deliveryMethodXml)); + if (isset($xml->deliveryMethod)) { + foreach ($xml->deliveryMethod as $deliveryMethodXml) { + $productConfiguration->addDeliveryMethod( + DeliveryMethod::createFromXML($deliveryMethodXml) + ); } } diff --git a/src/Bpost/ProductConfiguration/Characteristic.php b/src/Bpost/ProductConfiguration/Characteristic.php index 2b820404..5fdc6ec0 100644 --- a/src/Bpost/ProductConfiguration/Characteristic.php +++ b/src/Bpost/ProductConfiguration/Characteristic.php @@ -1,4 +1,5 @@ - */ + * Exemple : + * + */ $attributes = $xml->attributes(); - $option = new self(); - $option->setDisplayValue($attributes['displayValue']); - $option->setValue($attributes['value']); - $option->setName($attributes['name']); + $instance = new self(); + $instance->setDisplayValue((string) $attributes['displayValue']); + $instance->setValue((int) $attributes['value']); + $instance->setName((string) $attributes['name']); - return $option; + return $instance; } - /** - * @return string - */ - public function getDisplayValue() + public function getDisplayValue(): string { return $this->displayValue; } - /** - * @param string $displayValue - */ - public function setDisplayValue($displayValue) + public function setDisplayValue(string $displayValue): void { - $this->displayValue = (string) $displayValue; + $this->displayValue = $displayValue; } - /** - * @return int - */ - public function getValue() + public function getValue(): int { return $this->value; } - /** - * @param int $value - */ - public function setValue($value) + public function setValue(int $value): void { - $this->value = (int) $value; + $this->value = $value; } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } - /** - * @param string $name - */ - public function setName($name) + public function setName(string $name): void { - $this->name = (string) $name; + $this->name = $name; } -} +} \ No newline at end of file diff --git a/src/Bpost/ProductConfiguration/DeliveryMethod.php b/src/Bpost/ProductConfiguration/DeliveryMethod.php index e6130cba..075ef8d4 100644 --- a/src/Bpost/ProductConfiguration/DeliveryMethod.php +++ b/src/Bpost/ProductConfiguration/DeliveryMethod.php @@ -1,4 +1,5 @@ - */ $attributes = $xml->attributes(); - $children = $xml->children(); + $children = $xml->children(); - $deliveryMethod = new self(); - $deliveryMethod->setName($attributes['name']); - $deliveryMethod->setVisibility($attributes['visiblity']); + $instance = new self(); + if (isset($attributes['name'])) { + $instance->setName((string) $attributes['name']); + } + // Correction de l'attribut: visibility (et fallback si l’API renvoie l’ancienne coquille) + if (isset($attributes['visibility'])) { + $instance->setVisibility((string) $attributes['visibility']); + } elseif (isset($attributes['visiblity'])) { + $instance->setVisibility((string) $attributes['visiblity']); + } if (isset($children->product)) { foreach ($children->product as $productXml) { - $deliveryMethod->addProduct(Product::createFromXML($productXml)); + $instance->addProduct(Product::createFromXML($productXml)); } } - return $deliveryMethod; + return $instance; } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } - - /** - * @param string $name - */ - public function setName($name) + public function setName(string $name): void { - $this->name = (string) $name; + $this->name = $name; } - /** - * @return string - * - * @see Constants self::VISIBLITY_* - */ - public function getVisibility() + public function getVisibility(): string { return $this->visibility; } - /** - * @return bool - */ - public function isVisibleAndActive() + public function setVisibility(string $visibility): void { - return $this->getVisibility() === self::DELIVERY_METHOD_VISIBILITY_VISIBLE; + $this->visibility = $visibility; } - /** - * @param string $visibility - * - * @see Constants self::VISIBLITY_* - */ - public function setVisibility($visibility) + public function isVisibleAndActive(): bool { - $this->visibility = (string) $visibility; + return $this->getVisibility() === Visibility::DELIVERY_METHOD_VISIBILITY_VISIBLE; } - /** - * @return Product[] - */ - public function getProducts() + public function getProducts(): array { return $this->products; } - - /** - * @param Product $product - */ - public function addProduct(Product $product) + public function addProduct(Product $product): void { $this->products[] = $product; } -} +} \ No newline at end of file diff --git a/src/Bpost/ProductConfiguration/Option.php b/src/Bpost/ProductConfiguration/Option.php index 8229976d..44253876 100644 --- a/src/Bpost/ProductConfiguration/Option.php +++ b/src/Bpost/ProductConfiguration/Option.php @@ -1,4 +1,5 @@ - */ - $attributes = $xml->attributes(); + // Ex: