From a8e51e84cc15b46980e550007cc76a14cdae31bf Mon Sep 17 00:00:00 2001 From: Maxime Date: Wed, 27 Aug 2025 14:48:39 +0200 Subject: [PATCH 01/18] Delete old files --- .php-cs-fixer.dist.php | 32 - .scrutinizer.yml | 19 - .travis.yml | 22 - CHANGELOG.md | 83 - composer.lock | 3594 ---------------------- src/Bpost/Order/Box/Option/Insurance.php | 11 - src/Bpost/Order/Box/Option/Signature.php | 11 - src/Exception.php | 15 - src/tijsverkoyen_classes.php | 35 - 9 files changed, 3822 deletions(-) delete mode 100644 .php-cs-fixer.dist.php delete mode 100644 .scrutinizer.yml delete mode 100644 .travis.yml delete mode 100644 CHANGELOG.md delete mode 100644 composer.lock delete mode 100644 src/Bpost/Order/Box/Option/Insurance.php delete mode 100644 src/Bpost/Order/Box/Option/Signature.php delete mode 100644 src/Exception.php delete mode 100644 src/tijsverkoyen_classes.php 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.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/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 @@ - Date: Wed, 27 Aug 2025 14:49:05 +0200 Subject: [PATCH 02/18] Adapt the composer / workflow/phpunit --- .github/workflows/test.yml | 38 +++++++++++----------------- composer.json | 24 ++++++++---------- phpunit.xml.dist | 51 ++++++++++++++++---------------------- 3 files changed, 46 insertions(+), 67 deletions(-) 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/composer.json b/composer.json index 90a676a7..b6547749 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,21 @@ } ], "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": "*" - }, - "require-dev": { - "phpunit/phpunit": "^5", - "friendsofphp/php-cs-fixer": "=3.9.5" + "ext-simplexml": "*" }, "autoload": { "psr-4": { - "Bpost\\BpostApiClient\\": "src/", + "Bpost\\BpostApiClient\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { "Tests\\": "tests/" - }, - "classmap": [ - "src/tijsverkoyen_classes.php" - ] + } } -} +} \ No newline at end of file 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 + + - - - + + + + + From 12dc9d4287df9ca027eaab55f5151041970bd74d Mon Sep 17 00:00:00 2001 From: Maxime Date: Wed, 27 Aug 2025 14:49:21 +0200 Subject: [PATCH 03/18] Adapt the php files for 8.4 --- src/ApiCaller/ApiCaller.php | 1 + src/Bpack247.php | 1 + src/Bpack247/Customer.php | 1 + src/Bpack247/CustomerPackStation.php | 1 + src/Bpost.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabel.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabelForBox.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabelForBoxBuilder.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabelForOrder.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabelForOrderBuilder.php | 1 + src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrders.php | 1 + .../HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php | 1 + src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php | 1 + src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php | 1 + src/Bpost/HttpRequestBuilder/FetchOrder.php | 1 + src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php | 1 + src/Bpost/HttpRequestBuilder/FetchProductConfig.php | 1 + src/Bpost/HttpRequestBuilder/FetchProductConfigBuilder.php | 1 + src/Bpost/HttpRequestBuilder/HttpRequestBuilderInterface.php | 1 + src/Bpost/HttpRequestBuilder/ModifyOrder.php | 1 + src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php | 1 + src/Bpost/Label.php | 1 + src/Bpost/Label/Barcode.php | 1 + src/Bpost/Labels.php | 1 + src/Bpost/Order.php | 1 + src/Bpost/Order/Address.php | 1 + src/Bpost/Order/Box.php | 1 + src/Bpost/Order/Box/At247.php | 1 + src/Bpost/Order/Box/AtBpost.php | 1 + src/Bpost/Order/Box/AtHome.php | 1 + src/Bpost/Order/Box/BpostOnAppointment.php | 1 + src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php | 1 + src/Bpost/Order/Box/IBox.php | 1 + src/Bpost/Order/Box/International.php | 1 + src/Bpost/Order/Box/International/ParcelContent.php | 1 + src/Bpost/Order/Box/National.php | 1 + src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php | 1 + src/Bpost/Order/Box/National/ShopHandlingInstruction.php | 1 + src/Bpost/Order/Box/National/Unregistered.php | 1 + src/Bpost/Order/Box/OpeningHour/Day.php | 1 + src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php | 1 + src/Bpost/Order/Box/Option/CashOnDelivery.php | 1 + src/Bpost/Order/Box/Option/Insured.php | 1 + src/Bpost/Order/Box/Option/Messaging.php | 1 + src/Bpost/Order/Box/Option/Option.php | 1 + src/Bpost/Order/Box/Option/SaturdayDelivery.php | 1 + src/Bpost/Order/Box/Option/Signed.php | 1 + src/Bpost/Order/Customer.php | 1 + src/Bpost/Order/Line.php | 1 + src/Bpost/Order/ParcelsDepotAddress.php | 1 + src/Bpost/Order/PugoAddress.php | 1 + src/Bpost/Order/Receiver.php | 1 + src/Bpost/Order/Sender.php | 1 + src/Bpost/ProductConfiguration.php | 1 + src/Bpost/ProductConfiguration/Characteristic.php | 1 + src/Bpost/ProductConfiguration/DeliveryMethod.php | 1 + src/Bpost/ProductConfiguration/Option.php | 1 + src/Bpost/ProductConfiguration/Price.php | 1 + src/Bpost/ProductConfiguration/Product.php | 1 + src/Bpost/ProductConfiguration/Visibility.php | 1 + src/BpostException.php | 1 + src/Common/BasicAttribute.php | 1 + src/Common/BasicAttribute/EmailAddressCharacteristic.php | 1 + src/Common/BasicAttribute/Language.php | 1 + src/Common/BasicAttribute/PhoneNumber.php | 1 + src/Common/ComplexAttribute.php | 1 + src/Common/IAttribute.php | 1 + src/Common/ValidatedValue.php | 1 + src/Common/ValidatedValue/LabelFormat.php | 1 + src/Common/XmlHelper.php | 1 + src/Exception/BpostApiResponseException.php | 1 + .../BpostApiResponseException/BpostApiBusinessException.php | 1 + .../BpostApiResponseException/BpostApiSystemException.php | 1 + src/Exception/BpostApiResponseException/BpostCurlException.php | 1 + .../BpostApiResponseException/BpostInvalidResponseException.php | 1 + .../BpostApiResponseException/BpostInvalidSelectionException.php | 1 + .../BpostInvalidXmlResponseException.php | 1 + .../BpostApiResponseException/BpostTaxipostLocatorException.php | 1 + src/Exception/BpostLogicException.php | 1 + src/Exception/BpostLogicException/BpostInvalidDayException.php | 1 + .../BpostLogicException/BpostInvalidLengthException.php | 1 + .../BpostLogicException/BpostInvalidPatternException.php | 1 + src/Exception/BpostLogicException/BpostInvalidValueException.php | 1 + .../BpostLogicException/BpostInvalidWeightException.php | 1 + src/Exception/BpostNotImplementedException.php | 1 + src/Exception/BpostXmlException.php | 1 + src/Exception/XmlException/BpostXmlInvalidItemException.php | 1 + src/Exception/XmlException/BpostXmlNoReferenceFoundException.php | 1 + src/Exception/XmlException/BpostXmlNoUserIdFoundException.php | 1 + src/FormHandler.php | 1 + src/Geo6.php | 1 + src/Geo6/Day.php | 1 + src/Geo6/Poi.php | 1 + src/Geo6/Service.php | 1 + src/Logger.php | 1 + 96 files changed, 96 insertions(+) diff --git a/src/ApiCaller/ApiCaller.php b/src/ApiCaller/ApiCaller.php index 0c3283dd..3c26ee7a 100644 --- a/src/ApiCaller/ApiCaller.php +++ b/src/ApiCaller/ApiCaller.php @@ -1,4 +1,5 @@ Date: Thu, 28 Aug 2025 12:19:45 +0200 Subject: [PATCH 04/18] Continue the rework --- composer.json | 7 ++++++- src/Logger.php | 34 ---------------------------------- 2 files changed, 6 insertions(+), 35 deletions(-) delete mode 100644 src/Logger.php diff --git a/composer.json b/composer.json index b6547749..c8c8c88c 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,9 @@ "ext-dom": "*", "ext-simplexml": "*" }, + "require-dev": { + "phpunit/phpunit": "^11.2" + }, "autoload": { "psr-4": { "Bpost\\BpostApiClient\\": "src/" @@ -43,5 +46,7 @@ "psr-4": { "Tests\\": "tests/" } - } + }, + + "config": { "sort-packages": true } } \ No newline at end of file diff --git a/src/Logger.php b/src/Logger.php deleted file mode 100644 index ceda4eb5..00000000 --- a/src/Logger.php +++ /dev/null @@ -1,34 +0,0 @@ -logger = $logger; - } - - /** - * @param $message - * @param array $context - */ - public function debug($message, array $context = array()) - { - if ($this->logger) { - $this->logger->debug($message, $context); - } - } -} From be3f62bd59382d9446bcf96d4c92dee5fcd6b7db Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 28 Aug 2025 12:20:14 +0200 Subject: [PATCH 05/18] Correct method typing and param init --- src/ApiCaller/ApiCaller.php | 109 +++----- src/Bpack247/Customer.php | 455 ++++++++-------------------------- src/Common/BasicAttribute.php | 2 +- src/Common/ValidatedValue.php | 2 +- 4 files changed, 140 insertions(+), 428 deletions(-) diff --git a/src/ApiCaller/ApiCaller.php b/src/ApiCaller/ApiCaller.php index 3c26ee7a..a1875e40 100644 --- a/src/ApiCaller/ApiCaller.php +++ b/src/ApiCaller/ApiCaller.php @@ -3,13 +3,9 @@ namespace Bpost\BpostApiClient\ApiCaller; -use Bpost\BpostApiClient\Exception\BpostApiResponseException; -use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostApiBusinessException; -use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostApiSystemException; use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostCurlException; -use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostInvalidResponseException; -use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostInvalidXmlResponseException; -use Bpost\BpostApiClient\Logger; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; /** * Class ApiCaller @@ -18,100 +14,71 @@ */ class ApiCaller { - /** @var Logger */ - private $logger; + private ?int $responseHttpCode = null; + private string $responseBody = ''; + private ?string $responseContentType = null; - /** @var int */ - private $responseHttpCode; + public function __construct( + private readonly LoggerInterface $logger = new NullLogger() + ) {} - /** @var string */ - private $responseBody; - /** @var string */ - private $responseContentType; - - /** - * ApiCaller constructor. - * - * @param Logger $logger - */ - public function __construct(Logger $logger = null) - { - $this->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); + } } /** @@ -122,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/Customer.php b/src/Bpack247/Customer.php index 9ef825be..8a821624 100644 --- a/src/Bpack247/Customer.php +++ b/src/Bpack247/Customer.php @@ -17,385 +17,205 @@ */ class Customer { - const CUSTOMER_PREFERRED_LANGUAGE_NL = 'nl-BE'; - const CUSTOMER_PREFERRED_LANGUAGE_FR = 'fr-BE'; - const CUSTOMER_PREFERRED_LANGUAGE_EN = 'en-US'; + public const CUSTOMER_PREFERRED_LANGUAGE_NL = 'nl-BE'; + public const CUSTOMER_PREFERRED_LANGUAGE_FR = 'fr-BE'; + public const CUSTOMER_PREFERRED_LANGUAGE_EN = 'en-US'; const CUSTOMER_TITLE_MR = 'Mr.'; const CUSTOMER_TITLE_MS = 'Ms.'; - /** - * @var bool - */ - private $activated; - - /** - * @var string - */ - private $userID; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $companyName; - - /** - * @var string - */ - private $street; - - /** - * @var string - */ - private $number; - - /** - * @var string - */ - private $email; - - /** - * @var string - */ - private $mobilePrefix = '0032'; - - /** - * @var string - */ - private $mobileNumber; - - /** - * @var string - */ - private $postalCode; - - /** - * @var array - */ - private $packStations = array(); - - /** - * @var string - */ - private $town; - - /** - * @var string - */ - private $preferredLanguage; - - /** - * @var string - */ - private $title; - - /** - * @var bool - */ - private $isComfortZoneUser; - - /** - * @var DateTime - */ - private $dateOfBirth; - - /** - * @var string - */ - private $deliveryCode; - - /** - * @var bool - */ - private $optIn; - - /** - * @var bool - */ - private $receivePromotions; - - /** - * @var bool - */ - private $useInformationForThirdParty; - - /** - * @var string - */ - private $userName; - - /** - * @param bool $activated - */ - public function setActivated($activated) + public function __construct( + private ?bool $activated = null, + private ?string $userID = null, + private ?string $firstName = null, + private ?string $lastName = null, + private ?string $companyName = null, + private ?string $street = null, + private ?string $number = null, + private ?string $email = null, + private string $mobilePrefix = '0032', + private ?string $mobileNumber = null, + private ?string $postalCode = null, + private array $packStations = [], + private ?string $town = null, + private ?string $preferredLanguage = null, + private ?string $title = null, + private ?bool $isComfortZoneUser = null, + private ?\DateTime $dateOfBirth = null, + private ?string $deliveryCode = null, + private ?bool $optIn = null, + private ?bool $receivePromotions = null, + private ?bool $useInformationForThirdParty = null, + private ?string $userName = null, + ) {} + + + public function setActivated(?bool $activated): void { $this->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( self::CUSTOMER_PREFERRED_LANGUAGE_NL, @@ -404,64 +224,47 @@ public static function getPossiblePreferredLanguageValues() ); } - /** - * @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( self::CUSTOMER_TITLE_MR, @@ -469,78 +272,47 @@ public static function getPossibleTitleValues() ); } - /** - * @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' @@ -571,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)) { @@ -638,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 .= '.'; } @@ -667,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( @@ -691,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( @@ -723,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( @@ -747,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( @@ -763,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( @@ -779,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/Common/BasicAttribute.php b/src/Common/BasicAttribute.php index dd288d49..8821409a 100644 --- a/src/Common/BasicAttribute.php +++ b/src/Common/BasicAttribute.php @@ -56,7 +56,7 @@ public function getKey() /** * @return string */ - public function __toString() + public function __toString(): string { return (string) $this->getValue(); } diff --git a/src/Common/ValidatedValue.php b/src/Common/ValidatedValue.php index 25f27e67..e0588b12 100644 --- a/src/Common/ValidatedValue.php +++ b/src/Common/ValidatedValue.php @@ -46,7 +46,7 @@ public function setValue($value) /** * @return string */ - public function __toString() + public function __toString(): string { return (string) $this->getValue(); } From ae7cfffda6bbaf8c8ac11df6fae28de8430d8eb9 Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 28 Aug 2025 12:30:14 +0200 Subject: [PATCH 06/18] Modernize the CustomerPackStation --- src/Bpack247/Customer.php | 14 +++--- src/Bpack247/CustomerPackStation.php | 70 ++++++++-------------------- 2 files changed, 26 insertions(+), 58 deletions(-) diff --git a/src/Bpack247/Customer.php b/src/Bpack247/Customer.php index 8a821624..51645d67 100644 --- a/src/Bpack247/Customer.php +++ b/src/Bpack247/Customer.php @@ -21,8 +21,8 @@ class Customer public const CUSTOMER_PREFERRED_LANGUAGE_FR = 'fr-BE'; public const CUSTOMER_PREFERRED_LANGUAGE_EN = 'en-US'; - const CUSTOMER_TITLE_MR = 'Mr.'; - const CUSTOMER_TITLE_MS = 'Ms.'; + public const CUSTOMER_TITLE_MR = 'Mr.'; + public const CUSTOMER_TITLE_MS = 'Ms.'; public function __construct( private ?bool $activated = null, @@ -41,7 +41,7 @@ public function __construct( private ?string $preferredLanguage = null, private ?string $title = null, private ?bool $isComfortZoneUser = null, - private ?\DateTime $dateOfBirth = null, + private ?DateTime $dateOfBirth = null, private ?string $deliveryCode = null, private ?bool $optIn = null, private ?bool $receivePromotions = null, @@ -217,11 +217,11 @@ public function getPreferredLanguage(): ?string public static function getPossiblePreferredLanguageValues(): array { - return array( + return [ self::CUSTOMER_PREFERRED_LANGUAGE_NL, self::CUSTOMER_PREFERRED_LANGUAGE_FR, self::CUSTOMER_PREFERRED_LANGUAGE_EN, - ); + ]; } public function setReceivePromotions(?bool $receivePromotions): void @@ -266,10 +266,10 @@ public function getTitle(): ?string public static function getPossibleTitleValues(): array { - return array( + return [ self::CUSTOMER_TITLE_MR, self::CUSTOMER_TITLE_MS, - ); + ]; } public function setTown(?string $town): void diff --git a/src/Bpack247/CustomerPackStation.php b/src/Bpack247/CustomerPackStation.php index f6c76920..582d18d8 100644 --- a/src/Bpack247/CustomerPackStation.php +++ b/src/Bpack247/CustomerPackStation.php @@ -12,86 +12,54 @@ */ class CustomerPackStation { - /** - * @var string - */ - private $customLabel; + public function __construct( + private ?string $customLabel = null, + private ?string $orderNumber = null, + private ?string $packstationId = null, + ) {} - /** - * @var string - */ - private $orderNumber; - - /** - * @var string - */ - private $packstationId; - - /** - * @param string $customLabel - */ - public function setCustomLabel($customLabel) + public function setCustomLabel(?string $customLabel): void { $this->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; From efa333ee38f2c2d354628556084539b094a9084c Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 28 Aug 2025 15:02:06 +0200 Subject: [PATCH 07/18] Adapt the HttpRequestBuilder --- src/Bpost/HttpRequestBuilder/CreateLabel.php | 73 ++++---------- .../HttpRequestBuilder/CreateLabelBuilder.php | 76 ++++---------- .../HttpRequestBuilder/CreateLabelForBox.php | 2 +- .../CreateLabelForBoxBuilder.php | 2 +- .../CreateLabelForOrder.php | 2 +- .../CreateLabelForOrderBuilder.php | 2 +- .../CreateLabelInBulkForOrders.php | 92 +++++++---------- .../CreateLabelInBulkForOrdersBuilder.php | 98 +++++++------------ .../CreateOrReplaceOrder.php | 58 ++++------- .../CreateOrReplaceOrderBuilder.php | 57 +++-------- src/Bpost/HttpRequestBuilder/FetchOrder.php | 44 +++------ .../HttpRequestBuilder/FetchOrderBuilder.php | 44 +++------ .../HttpRequestBuilder/FetchProductConfig.php | 28 +++--- .../FetchProductConfigBuilder.php | 27 ++--- .../HttpRequestBuilderInterface.php | 14 +-- src/Bpost/HttpRequestBuilder/ModifyOrder.php | 65 +++++------- .../HttpRequestBuilder/ModifyOrderBuilder.php | 63 +++++------- src/Common/ApiVersions.php | 16 +++ 18 files changed, 265 insertions(+), 498 deletions(-) create mode 100644 src/Common/ApiVersions.php diff --git a/src/Bpost/HttpRequestBuilder/CreateLabel.php b/src/Bpost/HttpRequestBuilder/CreateLabel.php index 52267d77..738e488c 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabel.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabel.php @@ -3,69 +3,42 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; use Bpost\BpostApiClient\Common\ValidatedValue\LabelFormat; abstract class CreateLabel implements HttpRequestBuilderInterface { - /** - * @var string - */ - protected $reference; - /** - * @var LabelFormat - */ - protected $labelFormat; - /** - * @var bool - */ - protected $asPdf; - /** - * @var bool - */ - protected $withReturnLabels; - - /** - * @param string $reference - * @param LabelFormat $labelFormat - * @param bool $asPdf - * @param bool $withReturnLabels - */ - public function __construct($reference, LabelFormat $labelFormat, $asPdf, $withReturnLabels) - { - $this->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', @@ -76,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 19b38cbc..42a55870 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelBuilder.php @@ -3,69 +3,39 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; use Bpost\BpostApiClient\Common\ValidatedValue\LabelFormat; abstract class CreateLabelBuilder implements HttpRequestBuilderInterface { - /** - * @var string - */ - protected $reference; - /** - * @var LabelFormat - */ - protected $labelFormat; - /** - * @var bool - */ - protected $asPdf; - /** - * @var bool - */ - protected $withReturnLabels; - - /** - * @param string $reference - * @param LabelFormat $labelFormat - * @param bool $asPdf - * @param bool $withReturnLabels - */ - public function __construct($reference, LabelFormat $labelFormat, $asPdf, $withReturnLabels) - { - $this->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', @@ -76,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 a93e6971..47e80b42 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelForBox.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelForBox.php @@ -5,7 +5,7 @@ class CreateLabelForBox extends CreateLabel { - protected function getUrlPrefix() + protected function getUrlPrefix(): string { return 'boxes'; } diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelForBoxBuilder.php b/src/Bpost/HttpRequestBuilder/CreateLabelForBoxBuilder.php index 0faf9353..03f35a5b 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelForBoxBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelForBoxBuilder.php @@ -5,7 +5,7 @@ class CreateLabelForBoxBuilder extends CreateLabelBuilder { - protected function getUrlPrefix() + protected function getUrlPrefix(): string { return 'boxes'; } diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelForOrder.php b/src/Bpost/HttpRequestBuilder/CreateLabelForOrder.php index 7aa5da46..202c6f8d 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelForOrder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelForOrder.php @@ -5,7 +5,7 @@ class CreateLabelForOrder extends CreateLabel { - protected function getUrlPrefix() + protected function getUrlPrefix(): string { return 'orders'; } diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelForOrderBuilder.php b/src/Bpost/HttpRequestBuilder/CreateLabelForOrderBuilder.php index 41e92946..0bc82a86 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelForOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelForOrderBuilder.php @@ -5,7 +5,7 @@ class CreateLabelForOrderBuilder extends CreateLabelBuilder { - protected function getUrlPrefix() + protected function getUrlPrefix(): string { return 'orders'; } diff --git a/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrders.php b/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrders.php index 957edbde..cf2cc4f6 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrders.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrders.php @@ -3,55 +3,27 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; use Bpost\BpostApiClient\Common\ValidatedValue\LabelFormat; use DOMDocument; use DOMException; class CreateLabelInBulkForOrders implements HttpRequestBuilderInterface { - /** - * @var array - */ - protected $references; - /** - * @var LabelFormat - */ - protected $labelFormat; - /** - * @var bool - */ - protected $asPdf; - /** - * @var bool - */ - protected $withReturnLabels; - /** - * @var bool - */ - private $forcePrinting; - - /** - * @param array $references - * @param LabelFormat $labelFormat - * @param bool $asPdf - * @param bool $withReturnLabels - * @param bool $forcePrinting - */ - public function __construct($references, LabelFormat $labelFormat, $asPdf, $withReturnLabels, $forcePrinting) - { - $this->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; @@ -59,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 db68fb75..ac0c0221 100644 --- a/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateLabelInBulkForOrdersBuilder.php @@ -3,55 +3,22 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; use Bpost\BpostApiClient\Common\ValidatedValue\LabelFormat; use DOMDocument; use DOMException; class CreateLabelInBulkForOrdersBuilder implements HttpRequestBuilderInterface { - /** - * @var array - */ - protected $references; - /** - * @var LabelFormat - */ - protected $labelFormat; - /** - * @var bool - */ - protected $asPdf; - /** - * @var bool - */ - protected $withReturnLabels; - /** - * @var bool - */ - private $forcePrinting; + public function __construct( + private readonly array $references, + private readonly LabelFormat $labelFormat, + private readonly bool $asPdf, + private readonly bool $withReturnLabels, + private readonly bool $forcePrinting, + ) {} - /** - * @param array $references - * @param LabelFormat $labelFormat - * @param bool $asPdf - * @param bool $withReturnLabels - * @param bool $forcePrinting - */ - public function __construct($references, LabelFormat $labelFormat, $asPdf, $withReturnLabels, $forcePrinting) - { - $this->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; @@ -59,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 89d54455..d08c148f 100644 --- a/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php +++ b/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrder.php @@ -4,73 +4,49 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; use Bpost\BpostApiClient\Bpost\Order; +use Bpost\BpostApiClient\Common\ApiVersions; use DOMDocument; class CreateOrReplaceOrder implements HttpRequestBuilderInterface { - /** - * @var Order - */ - private $order; - /** - * @var string - */ - private $accountId; + public function __construct( + private readonly Order $order, + private readonly string $accountId, + ) {} - /** - * @param Order $order - * @param string $accountId - */ - public function __construct(Order $order, $accountId) - { - $this->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 a43651fa..a10fbf5a 100644 --- a/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/CreateOrReplaceOrderBuilder.php @@ -4,72 +4,47 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; use Bpost\BpostApiClient\Bpost\Order; +use Bpost\BpostApiClient\Common\ApiVersions; use DOMDocument; class CreateOrReplaceOrderBuilder implements HttpRequestBuilderInterface { - /** - * @var Order - */ - private $order; - /** - * @var string - */ - private $accountId; + public function __construct( + private readonly Order $order, + private readonly string $accountId, + ) {} - /** - * @param Order $order - * @param string $accountId - */ - public function __construct(Order $order, $accountId) + public function getXml(): string { - $this->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 4830961f..c1e3add3 100644 --- a/src/Bpost/HttpRequestBuilder/FetchOrder.php +++ b/src/Bpost/HttpRequestBuilder/FetchOrder.php @@ -3,54 +3,38 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; + class FetchOrder implements HttpRequestBuilderInterface { - /** - * @var string - */ - private $reference; - - /** - * @param string $reference - */ - public function __construct($reference) - { - $this->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 b5e25ae1..4d9b367f 100644 --- a/src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/FetchOrderBuilder.php @@ -3,54 +3,38 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; + class FetchOrderBuilder implements HttpRequestBuilderInterface { - /** - * @var string - */ - private $reference; - - /** - * @param string $reference - */ - public function __construct($reference) - { - $this->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 27883359..cdec4784 100644 --- a/src/Bpost/HttpRequestBuilder/FetchProductConfig.php +++ b/src/Bpost/HttpRequestBuilder/FetchProductConfig.php @@ -3,40 +3,34 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; + class FetchProductConfig implements HttpRequestBuilderInterface { - /** - * @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-productConfiguration-v3.1+XML', - ); + return [ + 'Accept: application/vnd.bpost.shm-productConfiguration-' . ApiVersions::V3_1 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/productconfig'; } - public function isExpectXml() + public function isExpectXml(): bool { return true; } - public function getMethod() + public function getMethod(): string { return self::METHOD_GET; } diff --git a/src/Bpost/HttpRequestBuilder/FetchProductConfigBuilder.php b/src/Bpost/HttpRequestBuilder/FetchProductConfigBuilder.php index d336542d..71a1327d 100644 --- a/src/Bpost/HttpRequestBuilder/FetchProductConfigBuilder.php +++ b/src/Bpost/HttpRequestBuilder/FetchProductConfigBuilder.php @@ -3,40 +3,33 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; +use Bpost\BpostApiClient\Common\ApiVersions; + class FetchProductConfigBuilder implements HttpRequestBuilderInterface { - /** - * @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-productConfiguration-v3.1+XML', - ); + return [ + 'Accept: application/vnd.bpost.shm-productConfiguration-' . ApiVersions::V3_1 . '+XML', + ]; } - /** - * @return string - */ - public function getUrl() + public function getUrl(): string { return '/productconfig'; } - public function isExpectXml() + public function isExpectXml(): bool { return true; } - public function getMethod() + public function getMethod(): string { return self::METHOD_GET; } diff --git a/src/Bpost/HttpRequestBuilder/HttpRequestBuilderInterface.php b/src/Bpost/HttpRequestBuilder/HttpRequestBuilderInterface.php index d8ddb686..995c12a2 100644 --- a/src/Bpost/HttpRequestBuilder/HttpRequestBuilderInterface.php +++ b/src/Bpost/HttpRequestBuilder/HttpRequestBuilderInterface.php @@ -5,16 +5,16 @@ interface HttpRequestBuilderInterface { - const METHOD_GET = 'GET'; - const METHOD_POST = 'POST'; + public const METHOD_GET = 'GET'; + public const METHOD_POST = 'POST'; - public function getHeaders(); + public function getHeaders(): array; - public function getUrl(); + public function getUrl(): string; - public function getXml(); + public function getXml(): ?string; - public function isExpectXml(); + public function isExpectXml(): bool; - public function getMethod(); + public function getMethod(): string; } diff --git a/src/Bpost/HttpRequestBuilder/ModifyOrder.php b/src/Bpost/HttpRequestBuilder/ModifyOrder.php index 81e00418..f6e3ae88 100644 --- a/src/Bpost/HttpRequestBuilder/ModifyOrder.php +++ b/src/Bpost/HttpRequestBuilder/ModifyOrder.php @@ -4,78 +4,63 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; use Bpost\BpostApiClient\Bpost\Order\Box; +use Bpost\BpostApiClient\Common\ApiVersions; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use DOMDocument; class ModifyOrder implements HttpRequestBuilderInterface { /** - * @var string + * @throws BpostInvalidValueException */ - private $reference; - /** - * @var string - */ - private $status; - - /** - * @param string $reference - * @param string $status - */ - public function __construct($reference, $status) - { - $this->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 b0e34cef..75b0c0af 100644 --- a/src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php +++ b/src/Bpost/HttpRequestBuilder/ModifyOrderBuilder.php @@ -4,77 +4,62 @@ namespace Bpost\BpostApiClient\Bpost\HttpRequestBuilder; use Bpost\BpostApiClient\Bpost\Order\Box; +use Bpost\BpostApiClient\Common\ApiVersions; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use DOMDocument; class ModifyOrderBuilder implements HttpRequestBuilderInterface { /** - * @var string + * @throws BpostInvalidValueException */ - private $reference; - /** - * @var string - */ - private $status; - - /** - * @param string $reference - * @param string $status - */ - public function __construct($reference, $status) - { - $this->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/Common/ApiVersions.php b/src/Common/ApiVersions.php new file mode 100644 index 00000000..cf097e3c --- /dev/null +++ b/src/Common/ApiVersions.php @@ -0,0 +1,16 @@ + Date: Mon, 1 Sep 2025 14:20:28 +0200 Subject: [PATCH 08/18] refactor(Order): migrate Order domain classes to strict typing and modern style - Added type hints and strict return types across all Order classes - Replaced constants by public const for clarity and PSR-12 compliance - Unified XML (toXML/createFromXML) signatures and logic - Simplified inheritance for Address, Customer, Receiver, Sender, etc. - Enforced validation exceptions (length, values) consistently - Improved code readability and maintainability --- src/Bpost/Label/Barcode.php | 52 +-- src/Bpost/Order/Address.php | 273 +++++---------- src/Bpost/Order/Box.php | 287 +++++----------- src/Bpost/Order/Box/At247.php | 292 +++++----------- src/Bpost/Order/Box/AtBpost.php | 269 +++++---------- src/Bpost/Order/Box/AtHome.php | 94 ++--- src/Bpost/Order/Box/BpostOnAppointment.php | 81 ++--- .../Order/Box/CustomsInfo/CustomsInfo.php | 323 ++++++------------ src/Bpost/Order/Box/IBox.php | 70 ++-- src/Bpost/Order/Box/International.php | 230 ++++--------- .../Order/Box/International/ParcelContent.php | 176 +++------- src/Bpost/Order/Box/National.php | 189 ++++------ .../ParcelLockerReducedMobilityZone.php | 23 +- .../Box/National/ShopHandlingInstruction.php | 7 +- src/Bpost/Order/Box/National/Unregistered.php | 152 +++------ src/Bpost/Order/Box/OpeningHour/Day.php | 86 ++--- .../Option/AutomaticSecondPresentation.php | 26 +- src/Bpost/Order/Box/Option/CashOnDelivery.php | 124 +++---- src/Bpost/Order/Box/Option/Insured.php | 141 +++----- src/Bpost/Order/Box/Option/Messaging.php | 232 +++++-------- src/Bpost/Order/Box/Option/Option.php | 8 +- .../Order/Box/Option/SaturdayDelivery.php | 11 +- src/Bpost/Order/Box/Option/Signed.php | 20 +- src/Bpost/Order/Customer.php | 161 +++------ src/Bpost/Order/Line.php | 92 ++--- src/Bpost/Order/ParcelsDepotAddress.php | 18 +- src/Bpost/Order/PugoAddress.php | 14 +- src/Bpost/Order/Receiver.php | 15 +- src/Bpost/Order/Sender.php | 14 +- 29 files changed, 1043 insertions(+), 2437 deletions(-) diff --git a/src/Bpost/Label/Barcode.php b/src/Bpost/Label/Barcode.php index 1bf760c3..15a3534c 100644 --- a/src/Bpost/Label/Barcode.php +++ b/src/Bpost/Label/Barcode.php @@ -10,63 +10,43 @@ */ class Barcode { - /** - * @var string - */ - private $barcode; + public function __construct( + private ?string $barcode = null, + private ?string $reference = null, + ) {} - /** - * @var string - */ - private $reference; - - /** - * @param string $barcode - */ - public function setBarcode($barcode) + public function setBarcode(?string $barcode): void { - $this->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/Order/Address.php b/src/Bpost/Order/Address.php index 95f9fe21..f342e690 100644 --- a/src/Bpost/Order/Address.php +++ b/src/Bpost/Order/Address.php @@ -16,221 +16,136 @@ */ class Address { - const TAG_NAME = 'common:address'; + public const TAG_NAME = 'common:address'; - /** - * @var string - */ - private $streetName; + private ?string $streetName = null; + private ?string $number = null; + private ?string $box = null; + private ?string $postalCode = null; + private ?string $locality = null; + private ?string $countryCode = 'BE'; /** - * @var string - */ - private $number; - - /** - * @var string - */ - private $box; - - /** - * @var string - */ - private $postalCode; - - /** - * @var string - */ - private $locality; - - /** - * @var string + * @throws BpostInvalidLengthException */ - private $countryCode = 'BE'; + public function __construct( + ?string $streetName = null, + ?string $number = null, + ?string $box = null, + ?string $postalCode = null, + ?string $locality = null, + ?string $countryCode = null + ) { + if ($streetName !== null) $this->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); + $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 - */ - public function __construct( - $streetName = null, - $number = null, - $box = null, - $postalCode = null, - $locality = null, - $countryCode = null - ) { - if ($streetName !== null) { - $this->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); - } - } - - /** - * 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 { - $tagName = static::TAG_NAME; - $address = $document->createElement($tagName); - $document->appendChild($address); + $address = $document->createElement(self::TAG_NAME); $this->streetToXML($document, $prefix, $address); $this->streetNumbersToXML($document, $prefix, $address); @@ -241,15 +156,11 @@ public function toXML(DOMDocument $document, $prefix = 'common') } /** - * @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); @@ -274,86 +185,60 @@ public static function createFromXML(SimpleXMLElement $xml) } /** - * @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 6d4d920b..765751dc 100644 --- a/src/Bpost/Order/Box.php +++ b/src/Bpost/Order/Box.php @@ -3,6 +3,8 @@ namespace Bpost\BpostApiClient\Bpost\Order; +use Bpost\BpostApiClient\Bpost\Order\Box\International; +use Bpost\BpostApiClient\Bpost\Order\Box\National; use Bpost\BpostApiClient\Common\XmlHelper; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use Bpost\BpostApiClient\Exception\BpostNotImplementedException; @@ -17,173 +19,107 @@ */ class Box { - const BOX_STATUS_OPEN = 'OPEN'; - const BOX_STATUS_PENDING = 'PENDING'; - const BOX_STATUS_PRINTED = 'PRINTED'; - const BOX_STATUS_CANCELLED = 'CANCELLED'; - const BOX_STATUS_ON_HOLD = 'ON-HOLD'; - const BOX_STATUS_ANNOUNCED = 'ANNOUNCED'; - const BOX_STATUS_IN_TRANSIT = 'IN_TRANSIT'; - const BOX_STATUS_AWAITING_PICKUP = 'AWAITING_PICKUP'; - const BOX_STATUS_DELIVERED = 'DELIVERED'; - const BOX_STATUS_BACK_TO_SENDER = 'BACK_TO_SENDER'; - - /** - * @var \Bpost\BpostApiClient\Bpost\Order\Sender - */ - private $sender; - - /** - * @var \Bpost\BpostApiClient\Bpost\Order\Box\AtHome - */ - private $nationalBox; - - /** - * @var \Bpost\BpostApiClient\Bpost\Order\Box\International - */ - private $internationalBox; - - /** - * @var string - */ - private $remark; - - /** - * @var string - */ - private $status; - - /** @var string */ - private $barcode; - - /** @var string */ - private $additionalCustomerReference; - - /** - * @param \Bpost\BpostApiClient\Bpost\Order\Box\International $internationalBox - */ - public function setInternationalBox(Box\International $internationalBox) + public const BOX_STATUS_OPEN = 'OPEN'; + public const BOX_STATUS_PENDING = 'PENDING'; + public const BOX_STATUS_PRINTED = 'PRINTED'; + public const BOX_STATUS_CANCELLED = 'CANCELLED'; + public const BOX_STATUS_ON_HOLD = 'ON-HOLD'; + public const BOX_STATUS_ANNOUNCED = 'ANNOUNCED'; + public const BOX_STATUS_IN_TRANSIT = 'IN_TRANSIT'; + public const BOX_STATUS_AWAITING_PICKUP = 'AWAITING_PICKUP'; + public const BOX_STATUS_DELIVERED = 'DELIVERED'; + public const BOX_STATUS_BACK_TO_SENDER = 'BACK_TO_SENDER'; + + private ?Sender $sender = null; + private ?National $nationalBox = null; + private ?International $internationalBox = null; + + private ?string $remark = null; + private ?string $status = null; + private ?string $barcode = null; + private ?string $additionalCustomerReference = null; + + public function setInternationalBox(International $internationalBox): void { $this->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, @@ -194,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)); @@ -219,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 5a91dc87..5c1f18bc 100644 --- a/src/Bpost/Order/Box/At247.php +++ b/src/Bpost/Order/Box/At247.php @@ -8,6 +8,7 @@ use Bpost\BpostApiClient\Bpost\Order\ParcelsDepotAddress; use Bpost\BpostApiClient\Bpost\ProductConfiguration\Product; use Bpost\BpostApiClient\Common\XmlHelper; +use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use Bpost\BpostApiClient\Exception\BpostNotImplementedException; use DOMDocument; @@ -26,306 +27,192 @@ */ class At247 extends National { - /** @var string */ - private $parcelsDepotId; - - /** @var string */ - private $parcelsDepotName; - - /** @var \Bpost\BpostApiClient\Bpost\Order\ParcelsDepotAddress */ - private $parcelsDepotAddress; - - /** @var string */ - protected $product = Product::PRODUCT_NAME_BPACK_24H_PRO; - - /** @var string */ - private $memberId; - - /** @var Unregistered */ - private $unregistered; + private ?string $parcelsDepotId = null; + private ?string $parcelsDepotName = null; + private ?ParcelsDepotAddress $parcelsDepotAddress = null; /** @var string */ - private $receiverName; + protected string $product = Product::PRODUCT_NAME_BPACK_24H_PRO; - /** @var string */ - private $receiverCompany; - - /** @var string */ - protected $requestedDeliveryDate; + private ?string $memberId = null; + private ?Unregistered $unregistered = null; + private ?string $receiverName = null; + private ?string $receiverCompany = null; + protected ?string $requestedDeliveryDate = null; - /** - * @param string $memberId - */ - public function setMemberId($memberId) + public function setMemberId(?string $memberId): void { $this->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); @@ -334,49 +221,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 e5b454f1..11f9f52a 100644 --- a/src/Bpost/Order/Box/AtBpost.php +++ b/src/Bpost/Order/Box/AtBpost.php @@ -8,6 +8,7 @@ use Bpost\BpostApiClient\Bpost\Order\PugoAddress; use Bpost\BpostApiClient\Bpost\ProductConfiguration\Product; use Bpost\BpostApiClient\Common\XmlHelper; +use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use Bpost\BpostApiClient\Exception\BpostNotImplementedException; use DOMDocument; @@ -26,210 +27,130 @@ */ class AtBpost extends National { - /** @var string */ - protected $product = Product::PRODUCT_NAME_BPACK_AT_BPOST; - - /** @var string */ - private $pugoId; - - /** @var string */ - private $pugoName; - - /** @var \Bpost\BpostApiClient\Bpost\Order\PugoAddress */ - private $pugoAddress; - - /** @var string */ - private $receiverName; - - /** @var string */ - private $receiverCompany; - - /** @var string */ - protected $requestedDeliveryDate; - - /** @var ShopHandlingInstruction */ - private $shopHandlingInstruction; + protected ?string $product = Product::PRODUCT_NAME_BPACK_AT_BPOST; + private ?string $pugoId = null; + private ?string $pugoName = null; + private ?PugoAddress $pugoAddress = null; + private ?string $receiverName = null; + private ?string $receiverCompany = null; + protected ?string $requestedDeliveryDate = null; + private ?ShopHandlingInstruction $shopHandlingInstruction = null; /** - * @param string $product Possible values are: bpack@bpost - * * @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_AT_BPOST, - ); + ]; } - /** - * @param \Bpost\BpostApiClient\Bpost\Order\PugoAddress $pugoAddress - */ - public function setPugoAddress($pugoAddress) + public function setPugoAddress(?PugoAddress $pugoAddress): void { $this->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, 'common')); } - 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); @@ -237,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); @@ -302,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 ee06c5e2..d9cb1f3b 100644 --- a/src/Bpost/Order/Box/AtHome.php +++ b/src/Bpost/Order/Box/AtHome.php @@ -24,93 +24,59 @@ */ class AtHome extends National { - /** @var \Bpost\BpostApiClient\Bpost\Order\Receiver */ - private $receiver; - - /** @var string */ - protected $requestedDeliveryDate; + private ?Receiver $receiver = null; + protected ?string $requestedDeliveryDate = null; /** - * @param string $product - * - * @see getPossibleProductValues - * * @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_24H_BUSINESS, Product::PRODUCT_NAME_BPACK_BUSINESS, Product::PRODUCT_NAME_BPACK_PALLET, Product::PRODUCT_NAME_BPACK_EASY_RETOUR, - ); + ]; } - /** - * @param \Bpost\BpostApiClient\Bpost\Order\Receiver $receiver - */ - public function setReceiver($receiver) + public function setReceiver(?Receiver $receiver): void { $this->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); @@ -119,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(); @@ -155,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)) { @@ -165,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 99ce3b90..283882ab 100644 --- a/src/Bpost/Order/Box/BpostOnAppointment.php +++ b/src/Bpost/Order/Box/BpostOnAppointment.php @@ -15,105 +15,64 @@ */ class BpostOnAppointment extends National { - /** @var Receiver */ - private $receiver; + private ?Receiver $receiver = null; + protected ?string $inNetworkCutOff = null; - /** @var string */ - protected $inNetworkCutOff; - - /** - * @param Receiver $receiver - */ - public function setReceiver(Receiver $receiver) + public function setReceiver(?Receiver $receiver): void { $this->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(); @@ -131,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 1d3c9f4c..78f99ab3 100644 --- a/src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php +++ b/src/Bpost/Order/Box/CustomsInfo/CustomsInfo.php @@ -23,45 +23,26 @@ */ class CustomsInfo { - const CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTA = 'RTA'; - const CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTS = 'RTS'; - const CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_ABANDONED = 'ABANDONED'; + public const CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTA = 'RTA'; + public const CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_RTS = 'RTS'; + public const CUSTOM_INFO_PARCEL_RETURN_INSTRUCTION_ABANDONED = 'ABANDONED'; - const CUSTOM_INFO_SHIPMENT_TYPE_SAMPLE = 'SAMPLE'; - const CUSTOM_INFO_SHIPMENT_TYPE_GIFT = 'GIFT'; - const CUSTOM_INFO_SHIPMENT_TYPE_GOODS = 'GOODS'; - const CUSTOM_INFO_SHIPMENT_TYPE_DOCUMENTS = 'DOCUMENTS'; - const CUSTOM_INFO_SHIPMENT_TYPE_OTHER = 'OTHER'; + public const CUSTOM_INFO_SHIPMENT_TYPE_SAMPLE = 'SAMPLE'; + public const CUSTOM_INFO_SHIPMENT_TYPE_GIFT = 'GIFT'; + public const CUSTOM_INFO_SHIPMENT_TYPE_GOODS = 'GOODS'; + public const CUSTOM_INFO_SHIPMENT_TYPE_DOCUMENTS = 'DOCUMENTS'; + public const CUSTOM_INFO_SHIPMENT_TYPE_OTHER = 'OTHER'; - const CUSTOM_INFO_CURRENCY_EUR = 'EUR'; - const CUSTOM_INFO_CURRENCY_GBP = 'GBP'; - const CUSTOM_INFO_CURRENCY_USD = 'USD'; - const CUSTOM_INFO_CURRENCY_CNY = 'CNY'; + public const CUSTOM_INFO_CURRENCY_EUR = 'EUR'; + public const CUSTOM_INFO_CURRENCY_GBP = 'GBP'; + public const CUSTOM_INFO_CURRENCY_USD = 'USD'; + public const CUSTOM_INFO_CURRENCY_CNY = 'CNY'; - /** - * @var int - */ - private $parcelValue; - - /** - * @var string - */ - private $contentDescription; - - /** - * @var string - */ - private $shipmentType; - - /** - * @var string - */ - private $parcelReturnInstructions; - - /** - * @var bool - */ - private $privateAddress; + private ?int $parcelValue = null; + private ?string $contentDescription = null; + private ?string $shipmentType = null; + private ?string $parcelReturnInstructions = null; + private ?bool $privateAddress = null; /** * this is the currency used for field parcelValue.In case of shipment to non-European country, @@ -69,9 +50,8 @@ class CustomsInfo * * Possible values are: EUR=Euro GBP=Pound Sterling USD=US Dollar CNY=Yuan Renminbi * - * @var string */ - private $currency; + private ?string $currency = null; /** * Amount paid by the sender for the sending of this shipment. See contract pricing with bpost. @@ -80,201 +60,168 @@ class CustomsInfo * Maximum value : 999.99 * Currency for field amtPostagePaidByAddresse is always EUR ! * - * @var float */ - private $amtPostagePaidByAddresse; + private ?float $amtPostagePaidByAddresse = null; + /** - * @param string $contentDescription - * * @throws BpostInvalidLengthException */ - public function setContentDescription($contentDescription) + public function setContentDescription(?string $contentDescription): void { + if ($contentDescription === null) { + $this->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)); @@ -290,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( @@ -378,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( @@ -397,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( @@ -416,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( @@ -435,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( @@ -454,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 954c1269..74b9ce1a 100644 --- a/src/Bpost/Order/Box/IBox.php +++ b/src/Bpost/Order/Box/IBox.php @@ -3,8 +3,9 @@ namespace Bpost\BpostApiClient\Bpost\Order\Box; -use DomDocument; -use DomElement; +use Bpost\BpostApiClient\Bpost\Order\Box\Option\Option; +use DOMDocument; +use DOMElement; use SimpleXMLElement; /** @@ -12,52 +13,19 @@ */ interface IBox { - /** - * @param array $options - */ - public function setOptions($options); - - /** - * @return array - */ - public function getOptions(); - - /** - * @param \Bpost\BpostApiClient\Bpost\Order\Box\Option\Option $option - */ - public function addOption(Option\Option $option); - - /** - * @param string $product - */ - public function setProduct($product); - - /** - * @return string - */ - public function getProduct(); - - /** - * @remark should be implemented by the child class - * - * @return array - */ - public static function getPossibleProductValues(); - - /** - * 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); - - /** - * @param SimpleXMLElement $xml - * - * @return self - */ - public static function createFromXML(SimpleXMLElement $xml); -} + public function setOptions(array $options): void; + + public function getOptions(): array; + + public function addOption(Option $option): void; + + public function setProduct(string $product): void; + + public function getProduct(): ?string; + + public static function getPossibleProductValues(): array; + + public function toXML(DOMDocument $document, ?string $prefix = null, ?string $type = null): DOMElement; + + public static function createFromXML(SimpleXMLElement $xml): self; +} \ No newline at end of file diff --git a/src/Bpost/Order/Box/International.php b/src/Bpost/Order/Box/International.php index 7502955a..45e81783 100644 --- a/src/Bpost/Order/Box/International.php +++ b/src/Bpost/Order/Box/International.php @@ -13,8 +13,8 @@ use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use Bpost\BpostApiClient\Exception\BpostNotImplementedException; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use DOMException; use SimpleXMLElement; @@ -30,245 +30,163 @@ */ class International implements IBox { - /** - * @var string - */ - private $product; + private ?string $product = null; - /** - * @var array - */ - private $options = array(); + private array $options = []; - /** - * @var Receiver - */ - private $receiver; + private ?Receiver $receiver = null; - /** - * @var int - */ - private $parcelWeight; + private ?int $parcelWeight = null; - /** - * @var CustomsInfo - */ - private $customsInfo; + private ?CustomsInfo $customsInfo = null; - /** - * Only for shipments outside Europe. - * Might include from 1 to 10 “parcelContent”. - * - * @var array|ParcelContent[] - */ - private $parcelContents = array(); + private array $parcelContents = []; - /** - * @param CustomsInfo $customsInfo - */ - public function setCustomsInfo($customsInfo) + public function setCustomsInfo(?CustomsInfo $customsInfo): void { $this->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); } @@ -277,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()) { @@ -306,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 9095af50..5c675c13 100644 --- a/src/Bpost/Order/Box/International/ParcelContent.php +++ b/src/Bpost/Order/Box/International/ParcelContent.php @@ -16,36 +16,29 @@ class ParcelContent { /** * Number of items of each type for the specified parcel content. - * - * @var int */ - private $numberOfItemType; + private ?int $numberOfItemType = null; /** * Value for the number of items and NOT per item * Max length = 50 - * Integer format in cents, for example for 10€, you must sent 1000, NO decima. - * - * @var string + * Integer format in cents, for example for 10€, you must sent 1000, NO decimal. */ - private $valueOfItem; + private ?int $valueOfItem = null; /** * description of parcel content * Max length = 30 characters. - * - * @var string */ - private $itemDescription; + private ?string $itemDescription = null; /** - * Weight for the number of itemsof each typeand NOT per item. + /** + * Weight for the number of items of each type and NOT per item. * Integer format, NO decimal ! In gramme (gr). * Range 1-30000. - * - * @var int */ - private $nettoWeight; + private ?int $nettoWeight = null; /** * HS stands for Harmonized System. @@ -53,230 +46,151 @@ class ParcelContent * Today, customs officers must use HS code to clear every commodity that enters or crosses any international borders. * Integer format, maximum 9 digits * you can find the code on https://www.tariffnumber.com/. - * - * @var string */ - private $hsTariffCode; + private ?string $hsTariffCode = null; /** * 2 letters country code from the orign of goods * you can find the code on https://countrycode.org/. - * - * @var string */ - private $originOfGoods; + private ?string $originOfGoods = null; - /** - * @return int - */ - public function getNumberOfItemType() + public function getNumberOfItemType(): ?int { return $this->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 69b59996..ed12293a 100644 --- a/src/Bpost/Order/Box/National.php +++ b/src/Bpost/Order/Box/National.php @@ -9,10 +9,12 @@ use Bpost\BpostApiClient\BpostException; use Bpost\BpostApiClient\Common\ComplexAttribute; use Bpost\BpostApiClient\Common\XmlHelper; +use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException; +use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use Bpost\BpostApiClient\Exception\BpostNotImplementedException; use Bpost\BpostApiClient\Exception\XmlException\BpostXmlInvalidItemException; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use SimpleXMLElement; /** @@ -27,183 +29,126 @@ */ abstract class National extends ComplexAttribute implements IBox { - /** @var string */ - protected $product; + protected ?string $product = null; /** @var Option[] */ - protected $options; + protected array $options = []; - /** @var int */ - protected $weight; + protected ?int $weight = null; /** @var Day[] */ - private $openingHours; + private array $openingHours = []; - /** @var string */ - private $desiredDeliveryPlace; + private ?string $desiredDeliveryPlace = null; - /** - * @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 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 ) ); } @@ -212,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); @@ -253,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 4f9e8988..8789342f 100644 --- a/src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php +++ b/src/Bpost/Order/Box/National/ParcelLockerReducedMobilityZone.php @@ -11,33 +11,18 @@ class ParcelLockerReducedMobilityZone extends ComplexAttribute { - /** - * @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 { $tagName = XmlHelper::getPrefixedTagName('parcelLockerReducedMobilityZone', $prefix); - - $xml = $document->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 6829c257..89909436 100644 --- a/src/Bpost/Order/Box/National/ShopHandlingInstruction.php +++ b/src/Bpost/Order/Box/National/ShopHandlingInstruction.php @@ -7,15 +7,12 @@ class ShopHandlingInstruction extends BasicAttribute { - public function validate() + public function validate(): void { $this->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 16d31fca..58e69cc0 100644 --- a/src/Bpost/Order/Box/National/Unregistered.php +++ b/src/Bpost/Order/Box/National/Unregistered.php @@ -14,178 +14,138 @@ class Unregistered extends ComplexAttribute { - /** @var Language */ - private $language; + private ?Language $language = null; + private ?PhoneNumber $mobilePhone = null; + private ?EmailAddressCharacteristic $emailAddress = null; + private ?ParcelLockerReducedMobilityZone $parcelLockerReducedMobilityZone = null; - /** @var PhoneNumber */ - private $mobilePhone; - - /** @var EmailAddressCharacteristic */ - private $emailAddress; - - /** @var ParcelLockerReducedMobilityZone */ - private $parcelLockerReducedMobilityZone; - - /** - * @return bool - */ - public function hasLanguage() + public function hasLanguage(): bool { return $this->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 6c09c11e..45503d84 100644 --- a/src/Bpost/Order/Box/OpeningHour/Day.php +++ b/src/Bpost/Order/Box/OpeningHour/Day.php @@ -5,8 +5,8 @@ use Bpost\BpostApiClient\Common\XmlHelper; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; /** * bPost Day class @@ -20,52 +20,45 @@ */ class Day { - const DAY_MONDAY = 'Monday'; - const DAY_TUESDAY = 'Tuesday'; - const DAY_WEDNESDAY = 'Wednesday'; - const DAY_THURSDAY = 'Thursday'; - const DAY_FRIDAY = 'Friday'; - const DAY_SATURDAY = 'Saturday'; - const DAY_SUNDAY = 'Sunday'; + public const DAY_MONDAY = 'Monday'; + public const DAY_TUESDAY = 'Tuesday'; + public const DAY_WEDNESDAY = 'Wednesday'; + public const DAY_THURSDAY = 'Thursday'; + public const DAY_FRIDAY = 'Friday'; + public const DAY_SATURDAY = 'Saturday'; + public const DAY_SUNDAY = 'Sunday'; - /** - * @var string - */ - private $day; + private string $day; + private string $value; /** - * @var string + * @throws BpostInvalidValueException */ - private $value; + public function __construct(string $day, string $value) + { + $this->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, @@ -73,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 c5bd83fc..c3507772 100644 --- a/src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php +++ b/src/Bpost/Order/Box/Option/AutomaticSecondPresentation.php @@ -4,8 +4,8 @@ namespace Bpost\BpostApiClient\Bpost\Order\Box\Option; use Bpost\BpostApiClient\Common\XmlHelper; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use SimpleXMLElement; /** @@ -21,25 +21,17 @@ class AutomaticSecondPresentation extends Option { /** - * 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 { - return $document->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 7db4a0aa..510e837e 100644 --- a/src/Bpost/Order/Box/Option/CashOnDelivery.php +++ b/src/Bpost/Order/Box/Option/CashOnDelivery.php @@ -4,8 +4,8 @@ namespace Bpost\BpostApiClient\Bpost\Order\Box\Option; use Bpost\BpostApiClient\Common\XmlHelper; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; /** * bPost CashOnDelivery class @@ -19,118 +19,76 @@ */ class CashOnDelivery extends Option { - /** - * @var float - */ - private $amount; - - /** - * @var string - */ - private $iban; + private float $amount; + private string $iban; + private string $bic; - /** - * @var string - */ - private $bic; + public function __construct(float $amount, string $iban, string $bic) + { + $this->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/Insured.php b/src/Bpost/Order/Box/Option/Insured.php index 34a0bf74..c515ea1b 100644 --- a/src/Bpost/Order/Box/Option/Insured.php +++ b/src/Bpost/Order/Box/Option/Insured.php @@ -5,8 +5,8 @@ use Bpost\BpostApiClient\Common\XmlHelper; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use DOMException; use SimpleXMLElement; @@ -22,91 +22,61 @@ */ class Insured extends Option { - const INSURANCE_TYPE_BASIC_INSURANCE = 'basicInsurance'; - const INSURANCE_TYPE_ADDITIONAL_INSURANCE = 'additionalInsurance'; - - const INSURANCE_AMOUNT_UP_TO_2500_EUROS = 2; - const INSURANCE_AMOUNT_UP_TO_5000_EUROS = 3; - const INSURANCE_AMOUNT_UP_TO_7500_EUROS = 4; - const INSURANCE_AMOUNT_UP_TO_10000_EUROS = 5; - const INSURANCE_AMOUNT_UP_TO_12500_EUROS = 6; - const INSURANCE_AMOUNT_UP_TO_15000_EUROS = 7; - const INSURANCE_AMOUNT_UP_TO_17500_EUROS = 8; - const INSURANCE_AMOUNT_UP_TO_20000_EUROS = 9; - const INSURANCE_AMOUNT_UP_TO_22500_EUROS = 10; - const INSURANCE_AMOUNT_UP_TO_25000_EUROS = 11; + public const INSURANCE_TYPE_BASIC_INSURANCE = 'basicInsurance'; + public const INSURANCE_TYPE_ADDITIONAL_INSURANCE = 'additionalInsurance'; + + public const INSURANCE_AMOUNT_UP_TO_2500_EUROS = 2; + public const INSURANCE_AMOUNT_UP_TO_5000_EUROS = 3; + public const INSURANCE_AMOUNT_UP_TO_7500_EUROS = 4; + public const INSURANCE_AMOUNT_UP_TO_10000_EUROS = 5; + public const INSURANCE_AMOUNT_UP_TO_12500_EUROS = 6; + public const INSURANCE_AMOUNT_UP_TO_15000_EUROS = 7; + public const INSURANCE_AMOUNT_UP_TO_17500_EUROS = 8; + public const INSURANCE_AMOUNT_UP_TO_20000_EUROS = 9; + public const INSURANCE_AMOUNT_UP_TO_22500_EUROS = 10; + public const INSURANCE_AMOUNT_UP_TO_25000_EUROS = 11; + + private string $type; + private ?int $value = null; /** - * @var string - */ - private $type; - - /** - * @var string + * @throws BpostInvalidValueException */ - private $value; + public function __construct(string $type, ?int $value = null) + { + $this->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, @@ -117,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)); @@ -152,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; @@ -179,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 1ee8aaac..0ef3ed4e 100644 --- a/src/Bpost/Order/Box/Option/Messaging.php +++ b/src/Bpost/Order/Box/Option/Messaging.php @@ -6,8 +6,8 @@ use Bpost\BpostApiClient\Common\XmlHelper; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use SimpleXMLElement; /** @@ -22,203 +22,141 @@ */ class Messaging extends Option { - const MESSAGING_LANGUAGE_EN = 'EN'; - const MESSAGING_LANGUAGE_NL = 'NL'; - const MESSAGING_LANGUAGE_FR = 'FR'; - const MESSAGING_LANGUAGE_DE = 'DE'; + public const MESSAGING_LANGUAGE_EN = 'EN'; + public const MESSAGING_LANGUAGE_NL = 'NL'; + public const MESSAGING_LANGUAGE_FR = 'FR'; + public const MESSAGING_LANGUAGE_DE = 'DE'; - const MESSAGING_TYPE_INFO_DISTRIBUTED = 'infoDistributed'; - const MESSAGING_TYPE_INFO_NEXT_DAY = 'infoNextDay'; - const MESSAGING_TYPE_INFO_REMINDER = 'infoReminder'; - const MESSAGING_TYPE_KEEP_ME_INFORMED = 'keepMeInformed'; + public const MESSAGING_TYPE_INFO_DISTRIBUTED = 'infoDistributed'; + public const MESSAGING_TYPE_INFO_NEXT_DAY = 'infoNextDay'; + public const MESSAGING_TYPE_INFO_REMINDER = 'infoReminder'; + public const MESSAGING_TYPE_KEEP_ME_INFORMED = 'keepMeInformed'; - /** - * @var string - */ - private $type; + private string $type; + private string $language; + private ?string $emailAddress = null; + private ?string $mobilePhone = null; /** - * @var string + * @throws BpostInvalidLengthException + * @throws BpostInvalidValueException */ - private $language; + public function __construct(string $type, string $language, ?string $emailAddress = null, ?string $mobilePhone = null) + { + $this->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) ); } @@ -226,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 ffbeeb12..53b05dee 100644 --- a/src/Bpost/Order/Box/Option/Option.php +++ b/src/Bpost/Order/Box/Option/Option.php @@ -18,11 +18,5 @@ */ abstract class Option { - /** - * @param DOMDocument $document - * @param string $prefix - * - * @return DOMElement - */ - abstract public function toXML(DOMDocument $document, $prefix = null); + abstract public function toXML(DOMDocument $document, ?string $prefix = null): DOMElement; } diff --git a/src/Bpost/Order/Box/Option/SaturdayDelivery.php b/src/Bpost/Order/Box/Option/SaturdayDelivery.php index 3a36518d..27ca5d32 100644 --- a/src/Bpost/Order/Box/Option/SaturdayDelivery.php +++ b/src/Bpost/Order/Box/Option/SaturdayDelivery.php @@ -5,7 +5,7 @@ use Bpost\BpostApiClient\Common\XmlHelper; use DOMDocument; -use DomElement; +use DOMElement; /** * bPost SaturdayDelivery class @@ -20,14 +20,9 @@ class SaturdayDelivery extends Option { /** - * 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 { return $document->createElement(XmlHelper::getPrefixedTagName('saturdayDelivery', $prefix)); } diff --git a/src/Bpost/Order/Box/Option/Signed.php b/src/Bpost/Order/Box/Option/Signed.php index 614ba2b3..3c215345 100644 --- a/src/Bpost/Order/Box/Option/Signed.php +++ b/src/Bpost/Order/Box/Option/Signed.php @@ -4,8 +4,8 @@ namespace Bpost\BpostApiClient\Bpost\Order\Box\Option; use Bpost\BpostApiClient\Common\XmlHelper; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use SimpleXMLElement; /** @@ -21,24 +21,14 @@ class Signed extends Option { /** - * 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 { return $document->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 eb1da5b2..af2cf7f9 100644 --- a/src/Bpost/Order/Customer.php +++ b/src/Bpost/Order/Customer.php @@ -5,8 +5,8 @@ use Bpost\BpostApiClient\Common\XmlHelper; use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException; -use DomDocument; -use DomElement; +use DOMDocument; +use DOMElement; use SimpleXMLElement; /** @@ -16,71 +16,38 @@ */ class Customer { - const TAG_NAME = 'customer'; + public const TAG_NAME = 'customer'; - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $company; - - /** - * @var Address - */ - private $address; + private ?string $name = null; + private ?string $company = null; + private ?Address $address = null; + private ?string $emailAddress = null; + private ?string $phoneNumber = null; - /** - * @var string - */ - private $emailAddress; - - /** - * @var string - */ - private $phoneNumber; - - /** - * @param \Bpost\BpostApiClient\Bpost\Order\Address $address - */ - public function setAddress($address) + public function setAddress(Address $address): void { $this->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) { @@ -89,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) { @@ -127,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() - ) - ); + $customer = $document->createElement(XmlHelper::getPrefixedTagName(self::TAG_NAME, $prefix)); + + 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)); } - 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 fcee7203..30adff1a 100644 --- a/src/Bpost/Order/Line.php +++ b/src/Bpost/Order/Line.php @@ -4,7 +4,7 @@ namespace Bpost\BpostApiClient\Bpost\Order; use Bpost\BpostApiClient\Common\XmlHelper; -use DomDocument; +use DOMDocument; use DOMElement; use SimpleXMLElement; @@ -15,109 +15,71 @@ */ class Line { - /** - * @var string - */ - private $text; + private ?string $text = null; + private ?int $numberOfItems = null; - /** - * @var int - */ - private $numberOfItems; + public function __construct(?string $text = null, ?int $numberOfItems = null) + { + if ($text !== null) { + $this->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 b415483d..1d5b4853 100644 --- a/src/Bpost/Order/ParcelsDepotAddress.php +++ b/src/Bpost/Order/ParcelsDepotAddress.php @@ -5,22 +5,8 @@ use SimpleXMLElement; -/** - * bPost ParcelsDepotAddress class - * - * @author Tijs Verkoyen - */ 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 8d0a9f58..d8eeebf4 100644 --- a/src/Bpost/Order/PugoAddress.php +++ b/src/Bpost/Order/PugoAddress.php @@ -3,8 +3,6 @@ namespace Bpost\BpostApiClient\Bpost\Order; -use SimpleXMLElement; - /** * bPost PugoAddress class * @@ -12,15 +10,5 @@ */ class PugoAddress extends Address { - const TAG_NAME = 'pugoAddress'; - - /** - * @param SimpleXMLElement $xml - * - * @return PugoAddress - */ - public static function createFromXML(SimpleXMLElement $xml) - { - return parent::createFromXML($xml); - } + public const TAG_NAME = 'pugoAddress'; } diff --git a/src/Bpost/Order/Receiver.php b/src/Bpost/Order/Receiver.php index 0b7d6188..dea70c7e 100644 --- a/src/Bpost/Order/Receiver.php +++ b/src/Bpost/Order/Receiver.php @@ -13,20 +13,15 @@ */ class Receiver extends Customer { - const TAG_NAME = 'receiver'; + public const TAG_NAME = 'receiver'; /** - * @param SimpleXMLElement $xml - * - * @return Receiver - * * @throws BpostInvalidLengthException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - /** @var Receiver $receiver */ - $receiver = parent::createFromXMLHelper($xml, new Receiver()); - + /** @var self $receiver */ + $receiver = parent::createFromXMLHelper($xml, new self()); return $receiver; } -} +} \ No newline at end of file diff --git a/src/Bpost/Order/Sender.php b/src/Bpost/Order/Sender.php index cdd77b05..4cf799f9 100644 --- a/src/Bpost/Order/Sender.php +++ b/src/Bpost/Order/Sender.php @@ -12,18 +12,12 @@ */ class Sender extends Customer { - const TAG_NAME = 'sender'; + public const TAG_NAME = 'sender'; - /** - * @param SimpleXMLElement $xml - * - * @return Sender - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - $sender = new Sender(); - $sender = parent::createFromXMLHelper($xml, $sender); - + /** @var self $sender */ + $sender = parent::createFromXMLHelper($xml, new self()); return $sender; } } From 189687eebe78c0a3c0afcd701aa9df67df1beb44 Mon Sep 17 00:00:00 2001 From: Maxime Date: Mon, 1 Sep 2025 14:20:42 +0200 Subject: [PATCH 09/18] =?UTF-8?q?refactor(Bpost):=20modernisation=20compl?= =?UTF-8?q?=C3=A8te=20du=20dossier=20Bpost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout de strict_types=1 sur toutes les classes - Typage strict des propriétés, méthodes et retours - Harmonisation des méthodes createFromXML avec retour typé - Correction des constantes et renommages cohérents - Simplification de Address et factorisation dans PugoAddress/ParcelsDepotAddress - Validation des valeurs (length, value, weight) via exceptions dédiées - Refactor des classes Order, Box, Label et ProductConfiguration - Nettoyage du code obsolète, docblocks et cohérence générale Dossier Bpost finalisé et prêt à l’usage --- src/Bpost/Label.php | 112 ++++------ src/Bpost/Labels.php | 15 +- src/Bpost/Order.php | 198 ++++-------------- src/Bpost/ProductConfiguration.php | 29 +-- .../ProductConfiguration/Characteristic.php | 69 ++---- .../ProductConfiguration/DeliveryMethod.php | 98 +++------ src/Bpost/ProductConfiguration/Option.php | 114 ++++------ src/Bpost/ProductConfiguration/Price.php | 153 +++++--------- src/Bpost/ProductConfiguration/Product.php | 159 +++++--------- src/Bpost/ProductConfiguration/Visibility.php | 9 +- 10 files changed, 302 insertions(+), 654 deletions(-) diff --git a/src/Bpost/Label.php b/src/Bpost/Label.php index 5d83a0d3..1dc39d68 100644 --- a/src/Bpost/Label.php +++ b/src/Bpost/Label.php @@ -14,113 +14,78 @@ */ class Label { - const LABEL_MIME_TYPE_IMAGE_PNG = 'image/png'; - const LABEL_MIME_TYPE_IMAGE_PDF = 'image/pdf'; - const LABEL_MIME_TYPE_APPLICATION_PDF = 'application/pdf'; + public const LABEL_MIME_TYPE_IMAGE_PNG = 'image/png'; + public const LABEL_MIME_TYPE_IMAGE_PDF = 'image/pdf'; + public const LABEL_MIME_TYPE_APPLICATION_PDF = 'application/pdf'; - /** - * @var Barcode[] - */ - private $barcodes; - - /** - * @var string - */ - private $mimeType; + private array $barcodes = []; + private ?string $mimeType = null; + private string $bytes = ''; - /** - * @var string - */ - private $bytes; - - /** - * @param Barcode $barcode - */ - public function addBarcode(Barcode $barcode) + public function addBarcode(Barcode $barcode): void { $this->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 */ @@ -132,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/Labels.php b/src/Bpost/Labels.php index a0364330..a75abdea 100644 --- a/src/Bpost/Labels.php +++ b/src/Bpost/Labels.php @@ -3,6 +3,7 @@ namespace Bpost\BpostApiClient\Bpost; +use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use SimpleXMLElement; /** @@ -11,20 +12,18 @@ class Labels { /** - * @param SimpleXMLElement $xml - * - * @return Label[] + * @throws BpostInvalidValueException */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): array { - $labels = array(); + $labels = []; if (isset($xml->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 c994806a..282ca404 100644 --- a/src/Bpost/Order.php +++ b/src/Bpost/Order.php @@ -5,6 +5,7 @@ use Bpost\BpostApiClient\Bpost\Order\Box; use Bpost\BpostApiClient\Bpost\Order\Line; +use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException; use Bpost\BpostApiClient\Exception\BpostNotImplementedException; use Bpost\BpostApiClient\Exception\XmlException\BpostXmlNoReferenceFoundException; use DOMDocument; @@ -20,246 +21,129 @@ class Order { /** * Order reference: unique ID used in your web shop to assign to an order. - * The value of this parameter is not managed by bpost. If the value - * already exists, it will update current order info. Existing boxes will - * not be changed, new boxes will be added. - * - * @var string + * If the value already exists, it will update current order info. + * Existing boxes will not be changed, new boxes will be added. */ - private $reference; + private string $reference; - /** - * This information is used on your invoice and allows you to attribute - * different cost centers - * - * @var string - */ - private $costCenter; + /** This information is used on your invoice and allows you to attribute different cost centers */ + private ?string $costCenter = null; - /** - * The items that are included in the order. - * Order lines are shown in the back end of the Shipping Manager and - * facilitate the use of the tool. - * - * @var array - */ - private $lines; + private array $lines = []; - /** - * Box tags - * - * @var array - */ - private $boxes; + private array $boxes = []; - /** - * Create an order - * - * @param string $reference - */ - public function __construct($reference) + public function __construct(string $reference) { $this->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/'); $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/ProductConfiguration.php b/src/Bpost/ProductConfiguration.php index 7b4cb95e..961defe8 100644 --- a/src/Bpost/ProductConfiguration.php +++ b/src/Bpost/ProductConfiguration.php @@ -11,38 +11,27 @@ */ class ProductConfiguration { - /** @var array DeliveryMethod[] */ - private $deliveryMethods = array(); + private array $deliveryMethods = []; - /** - * @return DeliveryMethod[] - */ - public function getDeliveryMethods() + public function getDeliveryMethods(): array { return $this->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 d0d2f8bb..5fdc6ec0 100644 --- a/src/Bpost/ProductConfiguration/Characteristic.php +++ b/src/Bpost/ProductConfiguration/Characteristic.php @@ -10,78 +10,53 @@ */ class Characteristic { - /** @var string */ - private $displayValue; - /** @var int */ - private $value; - /** @var string */ - private $name; + private string $displayValue; + private int $value; + private string $name; - /** - * @param SimpleXMLElement $xml - * - * @return Characteristic - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { /* - - */ + * 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 60d046ec..075ef8d4 100644 --- a/src/Bpost/ProductConfiguration/DeliveryMethod.php +++ b/src/Bpost/ProductConfiguration/DeliveryMethod.php @@ -10,105 +10,71 @@ */ class DeliveryMethod { - const DELIVERY_METHOD_NAME_HOME_OR_OFFICE = 'home or office'; - const DELIVERY_METHOD_NAME_PICKUP_POINT = 'pick-up point'; - const DELIVERY_METHOD_NAME_PARCEL_LOCKER = 'parcel locker'; - const DELIVERY_METHOD_NAME_CLICK_AND_COLLECT = 'Click & Collect'; + public const DELIVERY_METHOD_NAME_HOME_OR_OFFICE = 'home or office'; + public const DELIVERY_METHOD_NAME_PICKUP_POINT = 'pick-up point'; + public const DELIVERY_METHOD_NAME_PARCEL_LOCKER = 'parcel locker'; + public const DELIVERY_METHOD_NAME_CLICK_AND_COLLECT = 'Click & Collect'; - const DELIVERY_METHOD_VISIBILITY_VISIBLE = 'VISIBLE'; - const DELIVERY_METHOD_VISIBILITY_GREYED_OUT = 'GREYED_OUT'; - const DELIVERY_METHOD_VISIBILITY_INVISIBLE = 'INVISIBLE'; - - /** @var string */ - private $name; - /** @var string */ - private $visibility; + private string $name; + private string $visibility; /** @var Product[] */ - private $products = array(); + private array $products = []; - /** - * @param SimpleXMLElement $xml - * - * @return DeliveryMethod - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - /* - - */ $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 d46dc61e..44253876 100644 --- a/src/Bpost/ProductConfiguration/Option.php +++ b/src/Bpost/ProductConfiguration/Option.php @@ -10,107 +10,83 @@ */ class Option { - const OPTION_VISIBILITY_NOT_VISIBLE_BY_CONSUMER_OPTIONAL = 'NOT_VISIBLE_BY_CONSUMER_OPTIONAL'; - const OPTION_VISIBILITY_NOT_VISIBLE_BY_CONSUMER_DEFAULT = 'NOT_VISIBLE_BY_CONSUMER_DEFAULT'; - const OPTION_VISIBILITY_VISIBLE_BY_CONSUMER_AND_MANDATORY = 'VISIBLE_BY_CONSUMER_AND_MANDATORY'; - - /** @var string */ - private $visibility; - /** @var int */ - private $price; - /** @var string */ - private $name; + private string $visibility; + private int $price; + private string $name; /** @var Characteristic[] */ - private $characteristics = array(); + private array $characteristics = []; - /** - * @param SimpleXMLElement $xml - * - * @return Option - */ - public static function createFromXML(SimpleXMLElement $xml) + public static function createFromXML(SimpleXMLElement $xml): self { - /* -