From ba8a037aaf27cbb18cec6035f065462c9aa12621 Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Fri, 18 Jun 2021 17:52:25 -0300 Subject: [PATCH 1/8] Hotfix/20210618-01 (#19) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Correção no método setTid do StaticPayload --- CHANGELOG.md | 4 ++++ src/StaticPayload.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a471d22..bde7161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.1 - `2021-06-18` + +* Correção no método `setTid` do `StaticPayload`. + ## 2.0.0 * Release inicial da nova versão. diff --git a/src/StaticPayload.php b/src/StaticPayload.php index 80cabc1..a329d28 100644 --- a/src/StaticPayload.php +++ b/src/StaticPayload.php @@ -121,6 +121,7 @@ public function setDescription ( string $description ) * * @param string|null $tid Pix transaction id. * @since 2.0.0 + * @since 2.0.1 Fix remove of * char. * @return self */ public function setTid ( ?string $tid ) @@ -130,7 +131,7 @@ public function setTid ( ?string $tid ) if ( is_null( $tid ) ) { $_tid = Parser::getRandom(); } else - { $_tid = preg_replace('/[^A-Za-z0-9]+/', '', $tid);} + { $_tid = preg_replace('/[^A-Za-z0-9\*]+/', '', $tid);} $this->mpm->getEmv('62')->getField('05')->setValue($_tid); return $this; From 081925427c04d83ac1a4915dcaa854f8dab0bc57 Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 07:58:24 -0300 Subject: [PATCH 2/8] :arrow_double_up: dependencies(global): Update all dependencies and supports only PHP=>8 --- .php-cs-fixer.php | 19 + .prettierignore | 5 + .prettierrc.json | 10 + composer.json | 82 +- composer.lock | 1226 ++++++----------- phpunit.xml | 35 +- phpunit.xml.bak | 22 + src/Emv/MPM.php | 22 +- tests/Api/Payloads/CobTest.php | 64 +- tests/Api/Payloads/Entities/AmountTest.php | 33 +- tests/Api/Payloads/Entities/CalendarTest.php | 29 +- .../Entities/DueAmountModalityTest.php | 41 +- tests/Api/Payloads/Entities/LocationTest.php | 21 +- tests/Api/Payloads/Entities/PersonTest.php | 37 +- tests/Api/Payloads/Entities/PixTest.php | 29 +- tests/Api/Payloads/Entities/RefundTest.php | 35 +- tests/DynamicPayloadCreationTest.php | 34 +- tests/Emv/AbstractFieldTest.php | 24 +- tests/ParserTest.php | 43 +- tests/QrCodeCreationTest.php | 26 +- tests/ReaderTest.php | 24 +- tests/StaticPayloadCreationTest.php | 52 +- tests/ValidStaticPixTest.php | 39 +- 23 files changed, 774 insertions(+), 1178 deletions(-) create mode 100644 .php-cs-fixer.php create mode 100644 .prettierignore create mode 100644 .prettierrc.json create mode 100644 phpunit.xml.bak diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..15f1a62 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,19 @@ +setIndent("\t") + ->setRules([ + '@PSR12' => true, + ]) + ->setUsingCache(false) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->in(__DIR__) + ) +; diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..7f01864 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +/build +/coverage +/node_modules +*.yaml +*.yml \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..befa2f3 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,10 @@ +{ + "printWidth": 80, + "tabWidth": 3, + "useTabs": true, + "semi": true, + "singleQuote": true, + "bracketSpacing": true, + "bracketSameLine": true, + "arrowParens": "avoid" +} \ No newline at end of file diff --git a/composer.json b/composer.json index 1bf71ce..bbe2e5c 100644 --- a/composer.json +++ b/composer.json @@ -1,44 +1,42 @@ { - "name": "piggly/php-pix", - "description": "Uma biblioteca para preparar e gerar o código Pix do Banco Central do Brasil.", - "keywords": [ - "piggly", - "pix", - "bcb", - "emv", - "qrcode", - "payment" - ], - "type": "library", - "homepage": "https://github.com/piggly-dev/php-pix", - "autoload": { - "psr-4": { - "Piggly\\Pix\\": "src" - } - }, - "suggest": { - "piggly/php-api-client": "Recomentado para criar requisições HTTP seguras e dinâmicas para as API Pix junto com os Payloads padrões." - }, - "require": { - "php": "^7.2 || ^8.0", - "ext-gd": "*", - "chillerlan/php-qrcode": "^3.3" - }, - "require-dev": { - "php": "^7.3 || ^8.0", - "phpunit/phpunit": "^9.5", - "fakerphp/faker": "^1.14" - }, - "scripts": { - "test": "phpunit" - }, - "license": "MIT", - "authors": [ - { - "name": "Caique Araujo", - "email": "caique@studiopiggly.com.br", - "homepage": "https://github.com/caiquearaujo", - "role": "Developer" - } - ] + "name": "piggly/php-pix", + "description": "Uma biblioteca para preparar e gerar o código Pix do Banco Central do Brasil.", + "keywords": [ + "piggly", + "pix", + "bcb", + "emv", + "qrcode", + "payment" + ], + "type": "library", + "homepage": "https://github.com/piggly-dev/php-pix", + "autoload": { + "psr-4": { + "Piggly\\Pix\\": "src" + } + }, + "require": { + "php": "^8.0", + "ext-gd": "*", + "ext-mbstring": "*", + "chillerlan/php-qrcode": "^5.0" + }, + "require-dev": { + "php": "^8.0", + "phpunit/phpunit": "^11.1", + "fakerphp/faker": "^1.23" + }, + "scripts": { + "test": "phpunit" + }, + "license": "MIT", + "authors": [ + { + "name": "Caique Araujo", + "email": "caique@studiopiggly.com.br", + "homepage": "https://github.com/caiquearaujo", + "role": "Developer" + } + ] } diff --git a/composer.lock b/composer.lock index 10ff903..d65c453 100644 --- a/composer.lock +++ b/composer.lock @@ -4,34 +4,39 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9fd447620b32189be185631e735ea5fc", + "content-hash": "2ff091915b8f3209698e845d995e1f18", "packages": [ { "name": "chillerlan/php-qrcode", - "version": "3.4.0", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/chillerlan/php-qrcode.git", - "reference": "d8bf297e6843a53aeaa8f3285ce04fc349d133d6" + "reference": "da5bdb82c8755f54de112b271b402aaa8df53269" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/d8bf297e6843a53aeaa8f3285ce04fc349d133d6", - "reference": "d8bf297e6843a53aeaa8f3285ce04fc349d133d6", + "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/da5bdb82c8755f54de112b271b402aaa8df53269", + "reference": "da5bdb82c8755f54de112b271b402aaa8df53269", "shasum": "" }, "require": { - "chillerlan/php-settings-container": "^1.2", + "chillerlan/php-settings-container": "^2.1.4 || ^3.1", "ext-mbstring": "*", - "php": "^7.2" + "php": "^7.4 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5", - "setasign/fpdf": "^1.8.2" + "chillerlan/php-authenticator": "^4.1 || ^5.1", + "phan/phan": "^5.4", + "phpmd/phpmd": "^2.15", + "phpunit/phpunit": "^9.6", + "setasign/fpdf": "^1.8.2", + "squizlabs/php_codesniffer": "^3.8" }, "suggest": { "chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps.", - "setasign/fpdf": "Required to use the QR FPDF output." + "setasign/fpdf": "Required to use the QR FPDF output.", + "simple-icons/simple-icons": "SVG icons that you can use to embed as logos in the QR Code" }, "type": "library", "autoload": { @@ -41,12 +46,21 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "MIT", + "Apache-2.0" ], "authors": [ { "name": "Kazuhiko Arase", - "homepage": "https://github.com/kazuhikoarase" + "homepage": "https://github.com/kazuhikoarase/qrcode-generator" + }, + { + "name": "ZXing Authors", + "homepage": "https://github.com/zxing/zxing" + }, + { + "name": "Ashot Khanamiryan", + "homepage": "https://github.com/khanamiryan/php-qrcode-detector-decoder" }, { "name": "Smiley", @@ -58,18 +72,21 @@ "homepage": "https://github.com/chillerlan/php-qrcode/graphs/contributors" } ], - "description": "A QR code generator. PHP 7.2+", + "description": "A QR code generator and reader with a user friendly API. PHP 7.4+", "homepage": "https://github.com/chillerlan/php-qrcode", "keywords": [ "phpqrcode", "qr", "qr code", + "qr-reader", "qrcode", - "qrcode-generator" + "qrcode-generator", + "qrcode-reader" ], "support": { + "docs": "https://php-qrcode.readthedocs.io", "issues": "https://github.com/chillerlan/php-qrcode/issues", - "source": "https://github.com/chillerlan/php-qrcode/tree/3.4.0" + "source": "https://github.com/chillerlan/php-qrcode" }, "funding": [ { @@ -81,28 +98,31 @@ "type": "ko_fi" } ], - "time": "2020-11-18T20:51:41+00:00" + "time": "2024-02-27T14:37:26+00:00" }, { "name": "chillerlan/php-settings-container", - "version": "1.2.1", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/chillerlan/php-settings-container.git", - "reference": "b9b0431dffd74102ee92348a63b4c33fc8ba639b" + "reference": "8f93648fac8e6bacac8e00a8d325eba4950295e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/b9b0431dffd74102ee92348a63b4c33fc8ba639b", - "reference": "b9b0431dffd74102ee92348a63b4c33fc8ba639b", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/8f93648fac8e6bacac8e00a8d325eba4950295e6", + "reference": "8f93648fac8e6bacac8e00a8d325eba4950295e6", "shasum": "" }, "require": { "ext-json": "*", - "php": "^7.2" + "php": "^8.1" }, "require-dev": { - "phpunit/phpunit": "^8.3" + "phan/phan": "^5.4", + "phpmd/phpmd": "^2.15", + "phpunit/phpunit": "^10.5", + "squizlabs/php_codesniffer": "^3.9" }, "type": "library", "autoload": { @@ -121,11 +141,11 @@ "homepage": "https://github.com/codemasher" } ], - "description": "A container class for immutable settings objects. Not a DI container. PHP 7.2+", + "description": "A container class for immutable settings objects. Not a DI container.", "homepage": "https://github.com/chillerlan/php-settings-container", "keywords": [ - "PHP7", "Settings", + "configuration", "container", "helper" ], @@ -133,118 +153,57 @@ "issues": "https://github.com/chillerlan/php-settings-container/issues", "source": "https://github.com/chillerlan/php-settings-container" }, - "time": "2019-09-10T00:09:44+00:00" - } - ], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^8.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" - }, - "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.0" - }, "funding": [ { - "url": "https://www.doctrine-project.org/sponsorship.html", + "url": "https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4", "type": "custom" }, { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" + "url": "https://ko-fi.com/codemasher", + "type": "ko_fi" } ], - "time": "2020-11-10T18:47:58+00:00" - }, + "time": "2024-03-02T20:07:15+00:00" + } + ], + "packages-dev": [ { "name": "fakerphp/faker", - "version": "v1.14.1", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1" + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1", - "reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/bfb4fe148adbf78eff521199619b93a52ae3554b", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0", - "psr/container": "^1.0", - "symfony/deprecation-contracts": "^2.2" + "php": "^7.4 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "conflict": { "fzaninotto/faker": "*" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", "ext-intl": "*", - "symfony/phpunit-bridge": "^4.4 || ^5.2" + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" }, "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", "ext-curl": "Required by Faker\\Provider\\Image to download images.", "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", "ext-mbstring": "Required for multibyte Unicode string functionality." }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "v1.15-dev" - } - }, "autoload": { "psr-4": { "Faker\\": "src/Faker/" @@ -267,43 +226,44 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v.1.14.1" + "source": "https://github.com/FakerPHP/Faker/tree/v1.23.1" }, - "time": "2021-03-30T06:27:33+00:00" + "time": "2024-01-02T13:46:09+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.10.2", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "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": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -319,7 +279,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -327,29 +287,31 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "nikic/php-parser", - "version": "v4.10.5", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -357,7 +319,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -381,26 +343,27 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" }, - "time": "2021-05-03T19:11:20+00:00" + "time": "2024-03-05T20:51:40+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", - "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -441,22 +404,28 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/master" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2020-06-27T14:33:11+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", - "version": "3.1.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "bae7c545bef187884426f042434e561ab1ddb182" + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", - "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { @@ -492,275 +461,50 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.0" - }, - "time": "2021-02-23T14:00:09+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.2.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", - "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" - }, - "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/master" + "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2020-09-03T19:13:55+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" - }, - "time": "2020-09-17T18:55:26+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "1.13.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.13.0" - }, - "time": "2021-03-17T13:42:18+00:00" + "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.6", + "version": "11.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f6293e1b30a2354e8428e004689671b83871edde" + "reference": "7e35a2cbcabac0e6865fd373742ea432a3c34f92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde", - "reference": "f6293e1b30a2354e8428e004689671b83871edde", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e35a2cbcabac0e6865fd373742ea432a3c34f92", + "reference": "7e35a2cbcabac0e6865fd373742ea432a3c34f92", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.10.2", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", + "nikic/php-parser": "^5.0", + "php": ">=8.2", + "phpunit/php-file-iterator": "^5.0", + "phpunit/php-text-template": "^4.0", + "sebastian/code-unit-reverse-lookup": "^4.0", + "sebastian/complexity": "^4.0", + "sebastian/environment": "^7.0", + "sebastian/lines-of-code": "^3.0", + "sebastian/version": "^5.0", "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "11.0-dev" } }, "autoload": { @@ -788,7 +532,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.3" }, "funding": [ { @@ -796,32 +541,32 @@ "type": "github" } ], - "time": "2021-03-28T07:26:59+00:00" + "time": "2024-03-12T15:35:40+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.5", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + "reference": "99e95c94ad9500daca992354fa09d7b99abe2210" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/99e95c94ad9500daca992354fa09d7b99abe2210", + "reference": "99e95c94ad9500daca992354fa09d7b99abe2210", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -848,7 +593,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.0.0" }, "funding": [ { @@ -856,28 +602,28 @@ "type": "github" } ], - "time": "2020-09-28T05:57:25+00:00" + "time": "2024-02-02T06:05:04+00:00" }, { "name": "phpunit/php-invoker", - "version": "3.1.1", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + "reference": "5d8d9355a16d8cc5a1305b0a85342cfa420612be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5d8d9355a16d8cc5a1305b0a85342cfa420612be", + "reference": "5d8d9355a16d8cc5a1305b0a85342cfa420612be", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-pcntl": "*" @@ -885,7 +631,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -911,7 +657,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + "security": "https://github.com/sebastianbergmann/php-invoker/security/policy", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/5.0.0" }, "funding": [ { @@ -919,32 +666,32 @@ "type": "github" } ], - "time": "2020-09-28T05:58:55+00:00" + "time": "2024-02-02T06:05:50+00:00" }, { "name": "phpunit/php-text-template", - "version": "2.0.4", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + "reference": "d38f6cbff1cdb6f40b03c9811421561668cc133e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/d38f6cbff1cdb6f40b03c9811421561668cc133e", + "reference": "d38f6cbff1cdb6f40b03c9811421561668cc133e", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -970,7 +717,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/4.0.0" }, "funding": [ { @@ -978,32 +726,32 @@ "type": "github" } ], - "time": "2020-10-26T05:33:50+00:00" + "time": "2024-02-02T06:06:56+00:00" }, { "name": "phpunit/php-timer", - "version": "5.0.3", + "version": "7.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + "reference": "8a59d9e25720482ee7fcdf296595e08795b84dc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8a59d9e25720482ee7fcdf296595e08795b84dc5", + "reference": "8a59d9e25720482ee7fcdf296595e08795b84dc5", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -1029,7 +777,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + "security": "https://github.com/sebastianbergmann/php-timer/security/policy", + "source": "https://github.com/sebastianbergmann/php-timer/tree/7.0.0" }, "funding": [ { @@ -1037,24 +786,23 @@ "type": "github" } ], - "time": "2020-10-26T13:16:10+00:00" + "time": "2024-02-02T06:08:01+00:00" }, { "name": "phpunit/phpunit", - "version": "9.5.5", + "version": "11.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "89ff45ea9d70e35522fb6654a2ebc221158de276" + "reference": "d475be032238173ca3b0a516f5cc291d174708ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/89ff45ea9d70e35522fb6654a2ebc221158de276", - "reference": "89ff45ea9d70e35522fb6654a2ebc221158de276", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d475be032238173ca3b0a516f5cc291d174708ae", + "reference": "d475be032238173ca3b0a516f5cc291d174708ae", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -1062,34 +810,27 @@ "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.1", + "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.3", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.2", - "sebastian/version": "^3.0.2" - }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" + "php": ">=8.2", + "phpunit/php-code-coverage": "^11.0", + "phpunit/php-file-iterator": "^5.0", + "phpunit/php-invoker": "^5.0", + "phpunit/php-text-template": "^4.0", + "phpunit/php-timer": "^7.0", + "sebastian/cli-parser": "^3.0", + "sebastian/code-unit": "^3.0", + "sebastian/comparator": "^6.0", + "sebastian/diff": "^6.0", + "sebastian/environment": "^7.0", + "sebastian/exporter": "^6.0", + "sebastian/global-state": "^7.0", + "sebastian/object-enumerator": "^6.0", + "sebastian/type": "^5.0", + "sebastian/version": "^5.0" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files" }, "bin": [ "phpunit" @@ -1097,15 +838,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-main": "11.1-dev" } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1128,38 +869,48 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.5" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.1.3" }, "funding": [ { - "url": "https://phpunit.de/donate.html", + "url": "https://phpunit.de/sponsors.html", "type": "custom" }, { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2021-06-05T04:49:07+00:00" + "time": "2024-04-24T06:34:25+00:00" }, { "name": "psr/container", - "version": "1.1.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { - "php": ">=7.2.0" + "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -1186,34 +937,34 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-03-05T17:36:06+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "00a74d5568694711f0222e54fb281e1d15fdf04a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/00a74d5568694711f0222e54fb281e1d15fdf04a", + "reference": "00a74d5568694711f0222e54fb281e1d15fdf04a", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1236,7 +987,8 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/3.0.1" }, "funding": [ { @@ -1244,32 +996,32 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T07:26:58+00:00" }, { "name": "sebastian/code-unit", - "version": "1.0.8", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + "reference": "6634549cb8d702282a04a774e36a7477d2bd9015" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/6634549cb8d702282a04a774e36a7477d2bd9015", + "reference": "6634549cb8d702282a04a774e36a7477d2bd9015", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1292,7 +1044,8 @@ "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + "security": "https://github.com/sebastianbergmann/code-unit/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.0" }, "funding": [ { @@ -1300,32 +1053,32 @@ "type": "github" } ], - "time": "2020-10-26T13:08:54+00:00" + "time": "2024-02-02T05:50:41+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + "reference": "df80c875d3e459b45c6039e4d9b71d4fbccae25d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/df80c875d3e459b45c6039e4d9b71d4fbccae25d", + "reference": "df80c875d3e459b45c6039e4d9b71d4fbccae25d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1347,7 +1100,8 @@ "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/2.0.3" + "security": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/4.0.0" }, "funding": [ { @@ -1355,34 +1109,36 @@ "type": "github" } ], - "time": "2020-09-28T05:30:19+00:00" + "time": "2024-02-02T05:52:17+00:00" }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "bd0f2fa5b9257c69903537b266ccb80fcf940db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/bd0f2fa5b9257c69903537b266ccb80fcf940db8", + "reference": "bd0f2fa5b9257c69903537b266ccb80fcf940db8", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.2", + "sebastian/diff": "^6.0", + "sebastian/exporter": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1421,7 +1177,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/6.0.0" }, "funding": [ { @@ -1429,33 +1186,33 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2024-02-02T05:53:45+00:00" }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "88a434ad86150e11a606ac4866b09130712671f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/88a434ad86150e11a606ac4866b09130712671f0", + "reference": "88a434ad86150e11a606ac4866b09130712671f0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", - "php": ">=7.3" + "nikic/php-parser": "^5.0", + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1478,7 +1235,8 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/4.0.0" }, "funding": [ { @@ -1486,33 +1244,33 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2024-02-02T05:55:19+00:00" }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "6.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "ab83243ecc233de5655b76f577711de9f842e712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ab83243ecc233de5655b76f577711de9f842e712", + "reference": "ab83243ecc233de5655b76f577711de9f842e712", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^11.0", "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1544,7 +1302,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/6.0.1" }, "funding": [ { @@ -1552,27 +1311,27 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2024-03-02T07:30:33+00:00" }, { "name": "sebastian/environment", - "version": "5.1.3", + "version": "7.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + "reference": "4eb3a442574d0e9d141aab209cd4aaf25701b09a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4eb3a442574d0e9d141aab209cd4aaf25701b09a", + "reference": "4eb3a442574d0e9d141aab209cd4aaf25701b09a", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-posix": "*" @@ -1580,7 +1339,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-main": "7.1-dev" } }, "autoload": { @@ -1599,7 +1358,7 @@ } ], "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", + "homepage": "https://github.com/sebastianbergmann/environment", "keywords": [ "Xdebug", "environment", @@ -1607,7 +1366,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/7.1.0" }, "funding": [ { @@ -1615,34 +1375,34 @@ "type": "github" } ], - "time": "2020-09-28T05:52:38+00:00" + "time": "2024-03-23T08:56:34+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.3", + "version": "6.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" + "reference": "f291e5a317c321c0381fa9ecc796fa2d21b186da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", - "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f291e5a317c321c0381fa9ecc796fa2d21b186da", + "reference": "f291e5a317c321c0381fa9ecc796fa2d21b186da", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/recursion-context": "^4.0" + "ext-mbstring": "*", + "php": ">=8.2", + "sebastian/recursion-context": "^6.0" }, "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1677,14 +1437,15 @@ } ], "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", + "homepage": "https://www.github.com/sebastianbergmann/exporter", "keywords": [ "export", "exporter" ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/6.0.1" }, "funding": [ { @@ -1692,38 +1453,35 @@ "type": "github" } ], - "time": "2020-09-28T05:24:23+00:00" + "time": "2024-03-02T07:28:20+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.2", + "version": "7.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "a90ccbddffa067b51f574dea6eb25d5680839455" + "reference": "c3a307e832f2e69c7ef869e31fc644fde0e7cb3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455", - "reference": "a90ccbddffa067b51f574dea6eb25d5680839455", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c3a307e832f2e69c7ef869e31fc644fde0e7cb3e", + "reference": "c3a307e832f2e69c7ef869e31fc644fde0e7cb3e", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-uopz": "*" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -1742,13 +1500,14 @@ } ], "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", + "homepage": "https://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/5.0.2" + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/7.0.1" }, "funding": [ { @@ -1756,33 +1515,33 @@ "type": "github" } ], - "time": "2020-10-26T15:55:19+00:00" + "time": "2024-03-02T07:32:10+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "376c5b3f6b43c78fdc049740bca76a7c846706c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/376c5b3f6b43c78fdc049740bca76a7c846706c0", + "reference": "376c5b3f6b43c78fdc049740bca76a7c846706c0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", - "php": ">=7.3" + "nikic/php-parser": "^5.0", + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1805,7 +1564,8 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/3.0.0" }, "funding": [ { @@ -1813,34 +1573,34 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2024-02-02T06:00:36+00:00" }, { "name": "sebastian/object-enumerator", - "version": "4.0.4", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + "reference": "f75f6c460da0bbd9668f43a3dde0ec0ba7faa678" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f75f6c460da0bbd9668f43a3dde0ec0ba7faa678", + "reference": "f75f6c460da0bbd9668f43a3dde0ec0ba7faa678", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1862,7 +1622,8 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + "security": "https://github.com/sebastianbergmann/object-enumerator/security/policy", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/6.0.0" }, "funding": [ { @@ -1870,32 +1631,32 @@ "type": "github" } ], - "time": "2020-10-26T13:12:34+00:00" + "time": "2024-02-02T06:01:29+00:00" }, { "name": "sebastian/object-reflector", - "version": "2.0.4", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + "reference": "bb2a6255d30853425fd38f032eb64ced9f7f132d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/bb2a6255d30853425fd38f032eb64ced9f7f132d", + "reference": "bb2a6255d30853425fd38f032eb64ced9f7f132d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1917,7 +1678,8 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + "security": "https://github.com/sebastianbergmann/object-reflector/security/policy", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/4.0.0" }, "funding": [ { @@ -1925,32 +1687,32 @@ "type": "github" } ], - "time": "2020-10-26T13:14:26+00:00" + "time": "2024-02-02T06:02:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "b75224967b5a466925c6d54e68edd0edf8dd4ed4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b75224967b5a466925c6d54e68edd0edf8dd4ed4", + "reference": "b75224967b5a466925c6d54e68edd0edf8dd4ed4", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1977,10 +1739,11 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.0" }, "funding": [ { @@ -1988,87 +1751,32 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-02-02T06:08:48+00:00" }, { "name": "sebastian/type", - "version": "2.3.2", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1" + "reference": "b8502785eb3523ca0dd4afe9ca62235590020f3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0d1c587401514d17e8f9258a27e23527cb1b06c1", - "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8502785eb3523ca0dd4afe9ca62235590020f3f", + "reference": "b8502785eb3523ca0dd4afe9ca62235590020f3f", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2091,7 +1799,8 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3.2" + "security": "https://github.com/sebastianbergmann/type/security/policy", + "source": "https://github.com/sebastianbergmann/type/tree/5.0.0" }, "funding": [ { @@ -2099,29 +1808,29 @@ "type": "github" } ], - "time": "2021-06-04T13:02:07+00:00" + "time": "2024-02-02T06:09:34+00:00" }, { "name": "sebastian/version", - "version": "3.0.2", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" + "reference": "13999475d2cb1ab33cb73403ba356a814fdbb001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/13999475d2cb1ab33cb73403ba356a814fdbb001", + "reference": "13999475d2cb1ab33cb73403ba356a814fdbb001", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2144,7 +1853,8 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + "security": "https://github.com/sebastianbergmann/version/security/policy", + "source": "https://github.com/sebastianbergmann/version/tree/5.0.0" }, "funding": [ { @@ -2152,29 +1862,29 @@ "type": "github" } ], - "time": "2020-09-28T06:39:44+00:00" + "time": "2024-02-02T06:10:47+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.4.0", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -2203,7 +1913,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" }, "funding": [ { @@ -2219,99 +1929,20 @@ "type": "tidelift" } ], - "time": "2021-03-23T23:28:01+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.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": "2021-02-19T12:13:01+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.0", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "75a63c33a8577608444246075ea0af0d052e452a" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", - "reference": "75a63c33a8577608444246075ea0af0d052e452a", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -2340,7 +1971,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/master" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -2348,65 +1979,7 @@ "type": "github" } ], - "time": "2020-07-12T23:59:07+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "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.10.0" - }, - "time": "2021-03-09T10:59:23+00:00" + "time": "2024-03-03T12:36:25+00:00" } ], "aliases": [], @@ -2415,11 +1988,12 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2 || ^8.0", - "ext-gd": "*" + "php": "^8.0", + "ext-gd": "*", + "ext-mbstring": "*" }, "platform-dev": { - "php": "^7.3 || ^8.0" + "php": "^8.0" }, - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.6.0" } diff --git a/phpunit.xml b/phpunit.xml index a65c87a..3dc279f 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,13 @@ - - - - - ./tests - - - - - ./src - - - \ No newline at end of file + + + + + ./tests + + + + + ./src + + + diff --git a/phpunit.xml.bak b/phpunit.xml.bak new file mode 100644 index 0000000..a65c87a --- /dev/null +++ b/phpunit.xml.bak @@ -0,0 +1,22 @@ + + + + + ./tests + + + + + ./src + + + \ No newline at end of file diff --git a/src/Emv/MPM.php b/src/Emv/MPM.php index 8796137..6d3844e 100644 --- a/src/Emv/MPM.php +++ b/src/Emv/MPM.php @@ -3,7 +3,7 @@ /** * Payload to EMV MPM Format. - * + * * @see https://www.emvco.com/wp-content/plugins/pmpro-customizations/oy-getfile.php?u=/wp-content/uploads/documents/EMVCo-Merchant-Presented-QR-Specification-v1.1.pdf * @package \Piggly\Pix * @subpackage \Piggly\Pix\Emv @@ -20,7 +20,7 @@ class MPM /** * All emvs fields. * - * @var array + * @var array * @since 2.0.0 */ protected $emvs; @@ -32,10 +32,10 @@ class MPM * @since 2.0.0 */ protected $code; - + /** * All default EMVS. - * + * * @since 2.0.0 * @return void */ @@ -57,7 +57,7 @@ public function __construct () $this->emvs['26'] ->addField(new Field('00', 'Globally Unique Identifier', 32, true, 'br.gov.bcb.pix')) - ->addField(new Field('01', 'Pix Key', 36, false)) + ->addField(new Field('01', 'Pix Key', 77, false)) ->addField(new Field('02', 'Payment Description', 40, false)) ->addField(new Field('25', 'Payment URL', 77, false)); @@ -130,21 +130,21 @@ public function export ( bool $regenerate = false ) : string * @return string */ public static function CRC16 ( string $payload ) : string - { + { // Standard values by BACEN $polynomial = 0x1021; $response = 0xFFFF; // Checksum - if ( ( $length = \strlen($payload) ) > 0 ) + if ( ( $length = \strlen($payload) ) > 0 ) { - for ( $offset = 0; $offset < $length; $offset++ ) + for ( $offset = 0; $offset < $length; $offset++ ) { $response ^= ( \ord( $payload[$offset] ) << 8 ); - - for ( $bitwise = 0; $bitwise < 8; $bitwise++ ) + + for ( $bitwise = 0; $bitwise < 8; $bitwise++ ) { - if ( ( $response <<= 1 ) & 0x10000 ) + if ( ( $response <<= 1 ) & 0x10000 ) { $response ^= $polynomial; } $response &= 0xFFFF; diff --git a/tests/Api/Payloads/CobTest.php b/tests/Api/Payloads/CobTest.php index 5f18177..f14326b 100644 --- a/tests/Api/Payloads/CobTest.php +++ b/tests/Api/Payloads/CobTest.php @@ -3,6 +3,9 @@ use DateInterval; use DateTime; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Piggly\Pix\Api\Payloads\Cob; use Piggly\Pix\Api\Payloads\Entities\Amount; @@ -13,25 +16,22 @@ use Piggly\Pix\Api\Payloads\Entities\Pix; use Piggly\Pix\Api\Payloads\Entities\Refund; -/** - * @coversDefaultClass \Piggly\Pix\Api\Payloads\Cob - */ +#[CoversClass(Cob::class)] class CobTest extends TestCase { /** * Assert if $payload is equals to $obj exported. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::import * @covers ::export - * @dataProvider dataCobs - * @test Expecting positive assertion. * @param array $payload * @param Cob $obj * @return void */ + #[Test, DataProvider('dataCobs')] public function isMatching ( array $payload, Cob $obj ) { $this->assertEquals($payload, $obj->export()); } @@ -41,7 +41,7 @@ public function isMatching ( array $payload, Cob $obj ) * Generated by fakerphp. * @return array */ - public function dataCobs () : array + public static function dataCobs () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -51,14 +51,14 @@ public function dataCobs () : array $payload = []; $type = $faker->randomElement(Cob::TYPES); - $payload['calendario'] = $this->_getCalendar($faker, $type)->export(); + $payload['calendario'] = static::_getCalendar($faker, $type)->export(); if ( $faker->boolean() ) - { $payload['recebedor'] = $this->_getPerson($faker)->export(); } + { $payload['recebedor'] = static::_getPerson($faker)->export(); } - $payload['devedor'] = $this->_getPerson($faker)->export(); - $payload['valor'] = $this->_getAmount($faker, $type)->export(); - $payload['chave'] = $this->_getPixKey($faker); + $payload['devedor'] = static::_getPerson($faker)->export(); + $payload['valor'] = static::_getAmount($faker, $type)->export(); + $payload['chave'] = static::_getPixKey($faker); if ( $faker->boolean() ) { $payload['solicitacaoPagador'] = $faker->sentence(3); } @@ -75,12 +75,12 @@ public function dataCobs () : array $payload['status'] = $faker->randomElement(Cob::STATUSES); if ( $faker->boolean() ) - { $payload['loc'] = $this->_getLocation($faker, $type)->export(); } + { $payload['loc'] = static::_getLocation($faker, $type)->export(); } else { $payload['loc'] = ['id' => 0]; } if ( $faker->boolean() ) - { $payload['pix'] = $this->_getPix($faker)->export(); } + { $payload['pix'] = static::_getPix($faker)->export(); } $arr[] = [ $payload, (new Cob())->import($payload) ]; } @@ -94,7 +94,7 @@ public function dataCobs () : array * @param \Faker\Generator $faker * @return Person */ - private function _getPerson ( $faker ) : Person + private static function _getPerson ( $faker ) : Person { return (new Person()) ->setDocument($faker->boolean() ? $faker->cpf() : $faker->cnpj()) @@ -108,7 +108,7 @@ private function _getPerson ( $faker ) : Person * @param string $cobType * @return Location */ - private function _getLocation ( $faker, $cobType ) : Location + private static function _getLocation ( $faker, $cobType ) : Location { return (new Location()) ->setId(0) @@ -124,7 +124,7 @@ private function _getLocation ( $faker, $cobType ) : Location * @param string $cobType * @return Calendar */ - private function _getCalendar ( $faker, $cobType ) : Calendar + private static function _getCalendar ( $faker, $cobType ) : Calendar { if ( $cobType === Cob::TYPE_IMMEDIATE ) { return (new Calendar())->setCreatedAt(new DateTime())->setExpiresIn(3600); } @@ -142,14 +142,14 @@ private function _getCalendar ( $faker, $cobType ) : Calendar * @param string $cobType * @return Amount */ - private function _getAmount ( $faker, $cobType ) : Amount + private static function _getAmount ( $faker, $cobType ) : Amount { if ( $cobType === Cob::TYPE_IMMEDIATE ) { return (new Amount())->setOriginal($faker->randomFloat(2, 1, 999)); } return (new Amount()) ->setOriginal($faker->randomFloat(2, 1, 999)) - ->addModality($this->_getModality($faker)); + ->addModality(static::_getModality($faker)); } /** @@ -158,7 +158,7 @@ private function _getAmount ( $faker, $cobType ) : Amount * @param \Faker\Generator $faker * @return DueAmountModality */ - private function _getModality ( $faker ) : DueAmountModality + private static function _getModality ( $faker ) : DueAmountModality { $type = $faker->randomElement(DueAmountModality::MODALITIES); @@ -182,14 +182,14 @@ private function _getModality ( $faker ) : DueAmountModality ->setId($faker->randomElement($list)) ->setAmount(\number_format($faker->randomFloat(2, 1, 999), 2, '.', '')); } - + /** * Get a pix with random refunds. * * @param \Faker\Generator $faker * @return Refund */ - private function _getPix ( $faker ) : Pix + private static function _getPix ( $faker ) : Pix { $pix = new Pix(); @@ -203,19 +203,19 @@ private function _getPix ( $faker ) : Pix $random = $faker->numberBetween(1, 5); for ( $j = 0; $j < $random; $j++ ) - { $pix->addRefund($this->_getRefund($faker)); } + { $pix->addRefund(static::_getRefund($faker)); } } - + return $pix; } - + /** * Get a refund. * * @param \Faker\Generator $faker * @return Refund */ - private function _getRefund ( $faker ) : Refund + private static function _getRefund ( $faker ) : Refund { return (new Refund()) ->setId($faker->regexify('[0-9A-Za-z]{25}')) @@ -223,14 +223,14 @@ private function _getRefund ( $faker ) : Refund ->setAmount(\number_format($faker->randomFloat(2, 1, 999), 2, '.', '')) ->setStatus($faker->randomElement(Refund::STATUSES)); } - + /** * Get random pix key. - * + * * @param \Faker\Generator $faker * @return string */ - protected function _getPixKey ( $faker ) : string + private static function _getPixKey ( $faker ) : string { $num = $faker->numberBetween(0, 4); @@ -245,16 +245,16 @@ protected function _getPixKey ( $faker ) : string case 3: return '+55'.$faker->phoneNumberCleared(); case 4: - return $this->_genUuid(); + return static::_genUuid(); } } - + /** * Generate random uuidv4. * * @return void */ - protected function _genUuid () + private static function _genUuid () { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" diff --git a/tests/Api/Payloads/Entities/AmountTest.php b/tests/Api/Payloads/Entities/AmountTest.php index e4436ab..38d1bdd 100644 --- a/tests/Api/Payloads/Entities/AmountTest.php +++ b/tests/Api/Payloads/Entities/AmountTest.php @@ -1,36 +1,36 @@ assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * @@ -40,12 +40,11 @@ public function isMatching ( array $payload, Amount $obj ) * @covers ::getOriginal * @covers ::getFinal * @covers ::getModality - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } @@ -55,7 +54,7 @@ public function isMatchingFormat ( $expected, $actual ) * Generated by fakerphp. * @return array */ - public function dataAmounts () : array + public static function dataAmounts () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -70,16 +69,16 @@ public function dataAmounts () : array { $payload['final'] = \number_format($faker->randomFloat(2, 1, 999), 2, '.', ''); } if ( $faker->boolean() ) - { $payload[DueAmountModality::MODALITY_BANKFINE] = $this->_getModality($faker, DueAmountModality::MODALITY_BANKFINE)->export(); } + { $payload[DueAmountModality::MODALITY_BANKFINE] = static::_getModality($faker, DueAmountModality::MODALITY_BANKFINE)->export(); } if ( $faker->boolean() ) - { $payload[DueAmountModality::MODALITY_DISCOUNT] = $this->_getModality($faker, DueAmountModality::MODALITY_DISCOUNT)->export(); } + { $payload[DueAmountModality::MODALITY_DISCOUNT] = static::_getModality($faker, DueAmountModality::MODALITY_DISCOUNT)->export(); } if ( $faker->boolean() ) - { $payload[DueAmountModality::MODALITY_FEE] = $this->_getModality($faker, DueAmountModality::MODALITY_FEE)->export(); } + { $payload[DueAmountModality::MODALITY_FEE] = static::_getModality($faker, DueAmountModality::MODALITY_FEE)->export(); } if ( $faker->boolean() ) - { $payload[DueAmountModality::MODALITY_REDUCTION] = $this->_getModality($faker, DueAmountModality::MODALITY_REDUCTION)->export(); } + { $payload[DueAmountModality::MODALITY_REDUCTION] = static::_getModality($faker, DueAmountModality::MODALITY_REDUCTION)->export(); } $arr[] = [ $payload, (new Amount())->import($payload) ]; } @@ -93,7 +92,7 @@ public function dataAmounts () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -102,7 +101,7 @@ public function dataFormats () : array { $original = $faker->randomFloat(2, 1, 999); $final = $faker->randomFloat(2, 1, 999); - $modality = $this->_getModality($faker, DueAmountModality::MODALITY_BANKFINE); + $modality = static::_getModality($faker, DueAmountModality::MODALITY_BANKFINE); $amount = new Amount(); @@ -126,7 +125,7 @@ public function dataFormats () : array * @param string $type * @return DueAmountModality */ - private function _getModality ( $faker, $type ) : DueAmountModality + private static function _getModality ( $faker, $type ) : DueAmountModality { switch ( $type ) { diff --git a/tests/Api/Payloads/Entities/CalendarTest.php b/tests/Api/Payloads/Entities/CalendarTest.php index 5480169..9b4e0d0 100644 --- a/tests/Api/Payloads/Entities/CalendarTest.php +++ b/tests/Api/Payloads/Entities/CalendarTest.php @@ -2,45 +2,44 @@ namespace Piggly\Tests\Pix\Api\Entities; use DateTime; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Piggly\Pix\Api\Payloads\Entities\Calendar; -/** - * @coversDefaultClass \Piggly\Pix\Api\Payloads\Entities\Calendar - */ +#[CoversClass(Calendar::class)] class CalendarTest extends TestCase { /** * Assert if $payload is equals to $obj exported. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::import * @covers ::export - * @dataProvider dataCalendars - * @test Expecting positive assertion. * @param array $payload * @param Calendar $obj * @return void */ + #[Test, DataProvider('dataCalendars')] public function isMatching ( array $payload, Calendar $obj ) { $this->assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::setDocument * @covers ::getDocumentType - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } @@ -50,7 +49,7 @@ public function isMatchingFormat ( $expected, $actual ) * Generated by fakerphp. * @return array */ - public function dataCalendars () : array + public static function dataCalendars () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -58,19 +57,19 @@ public function dataCalendars () : array for ( $i = 0; $i < 100; $i++ ) { $payload = []; - + if ( $faker->boolean() ) { $array['criacao'] = $faker->dateTimeBetween('-1 week', '+1 week')->format(DateTime::RFC3339); } if ( $faker->boolean() ) { $array['apresentacao'] = $faker->dateTimeBetween('-1 week', '+1 week')->format(DateTime::RFC3339); } - + if ( $faker->boolean() ) { $array['expiracao'] = $faker->numberBetween(60, 3600); } - + if ( $faker->boolean() ) { $array['dataDeVencimento'] = $faker->dateTimeBetween('-1 week', '+1 week')->format('Y-m-d'); } - + if ( $faker->boolean() ) { $array['validadeAposVencimento'] = $faker->numberBetween(5, 30); } @@ -86,7 +85,7 @@ public function dataCalendars () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); diff --git a/tests/Api/Payloads/Entities/DueAmountModalityTest.php b/tests/Api/Payloads/Entities/DueAmountModalityTest.php index 9a58eba..d68a227 100644 --- a/tests/Api/Payloads/Entities/DueAmountModalityTest.php +++ b/tests/Api/Payloads/Entities/DueAmountModalityTest.php @@ -1,74 +1,71 @@ assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::setAmount * @covers ::getAmount - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } - + /** * Assert if throw an exception. * * @covers ::__construct - * @test Expecting positive assertion. * @return void */ + #[Test] public function throwTypeException () - { - $this->expectException(InvalidFieldException::class); + { + $this->expectException(InvalidFieldException::class); (new DueAmountModality('unknown')); } - + /** * Assert if throw an exception. * - * @covers ::setId - * @test Expecting positive assertion. + * @covers ::__construct * @return void */ + #[Test] public function throwIdException () - { - $this->expectException(InvalidFieldException::class); + { + $this->expectException(InvalidFieldException::class); (new DueAmountModality('juros'))->setId(99); } @@ -78,7 +75,7 @@ public function throwIdException () * Generated by fakerphp. * @return array */ - public function dataDueAmountModalities () : array + public static function dataDueAmountModalities () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -123,7 +120,7 @@ public function dataDueAmountModalities () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); diff --git a/tests/Api/Payloads/Entities/LocationTest.php b/tests/Api/Payloads/Entities/LocationTest.php index eec4be6..af300fd 100644 --- a/tests/Api/Payloads/Entities/LocationTest.php +++ b/tests/Api/Payloads/Entities/LocationTest.php @@ -2,46 +2,45 @@ namespace Piggly\Tests\Pix\Api\Entities; use DateTime; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Piggly\Pix\Api\Payloads\Cob; use Piggly\Pix\Api\Payloads\Entities\Location; -/** - * @coversDefaultClass \Piggly\Pix\Api\Payloads\Entities\Location - */ +#[CoversClass(Location::class)] class LocationTest extends TestCase { /** * Assert if $payload is equals to $obj exported. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::import * @covers ::export - * @dataProvider dataLocations - * @test Expecting positive assertion. * @param array $payload * @param Location $obj * @return void */ + #[Test, DataProvider('dataLocations')] public function isMatching ( array $payload, Location $obj ) { $this->assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::setCreatedAt * @covers ::getCreatedAt - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } @@ -51,7 +50,7 @@ public function isMatchingFormat ( $expected, $actual ) * Generated by fakerphp. * @return array */ - public function dataLocations () : array + public static function dataLocations () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -81,7 +80,7 @@ public function dataLocations () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); diff --git a/tests/Api/Payloads/Entities/PersonTest.php b/tests/Api/Payloads/Entities/PersonTest.php index 5622c64..36234f6 100644 --- a/tests/Api/Payloads/Entities/PersonTest.php +++ b/tests/Api/Payloads/Entities/PersonTest.php @@ -1,45 +1,44 @@ assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::setDocument * @covers ::getDocumentType - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } @@ -49,7 +48,7 @@ public function isMatchingFormat ( $expected, $actual ) * Generated by fakerphp. * @return array */ - public function dataPersons () : array + public static function dataPersons () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -57,31 +56,31 @@ public function dataPersons () : array for ( $i = 0; $i < 100; $i++ ) { $payload = []; - + $array['cpf'] = $faker->cpf(); - + // Random change to CNPJ if ( $faker->boolean() ) { $array['cnpj'] = $faker->cnpj(); unset($array['cpf']); } if ( $faker->boolean() ) { $array['nome'] = $faker->firstName().' '.$faker->lastName(); } - + if ( $faker->boolean() ) { $array['nomeFantasia'] = $faker->company(); } - + if ( $faker->boolean() ) { $array['cidade'] = $faker->city(); } - + if ( $faker->boolean() ) { $array['uf'] = $faker->stateAbbr(); } - + if ( $faker->boolean() ) { $array['logradouro'] = $faker->streetAddress(); } - + if ( $faker->boolean() ) { $array['cep'] = $faker->postcode(); } - + if ( $faker->boolean() ) { $array['email'] = $faker->email(); } @@ -97,7 +96,7 @@ public function dataPersons () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); diff --git a/tests/Api/Payloads/Entities/PixTest.php b/tests/Api/Payloads/Entities/PixTest.php index 5c97c50..b4b73fc 100644 --- a/tests/Api/Payloads/Entities/PixTest.php +++ b/tests/Api/Payloads/Entities/PixTest.php @@ -2,36 +2,36 @@ namespace Piggly\Tests\Pix\Api\Entities; use DateTime; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Piggly\Pix\Api\Payloads\Entities\Pix; use Piggly\Pix\Api\Payloads\Entities\Refund; -/** - * @coversDefaultClass \Piggly\Pix\Api\Payloads\Entities\Pix - */ +#[CoversClass(Pix::class)] class PixTest extends TestCase { /** * Assert if $payload is equals to $obj exported. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::import * @covers ::export * @covers Refund::export - * @dataProvider dataPixs - * @test Expecting positive assertion. * @param array $payload * @param Pix $obj * @return void */ + #[Test, DataProvider('dataPixs')] public function isMatching ( array $payload, Pix $obj ) { $this->assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * @@ -41,12 +41,11 @@ public function isMatching ( array $payload, Pix $obj ) * @covers ::getAmount * @covers ::getProcessedAt * @covers ::getRefund - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } @@ -56,7 +55,7 @@ public function isMatchingFormat ( $expected, $actual ) * Generated by fakerphp. * @return array */ - public function dataPixs () : array + public static function dataPixs () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -74,12 +73,12 @@ public function dataPixs () : array $payload['horario'] = $faker->dateTimeBetween('-1 week', '+1 week')->format(DateTime::RFC3339); if ( $faker->boolean() ) - { + { $payload['devolucoes'] = []; $random = $faker->numberBetween(1, 5); for ( $j = 0; $j < $random; $j++ ) - { $payload['devolucoes'][] = $this->_getRefund($faker)->export(); } + { $payload['devolucoes'][] = static::_getRefund($faker)->export(); } } $arr[] = [ $payload, (new Pix())->import($payload) ]; @@ -94,7 +93,7 @@ public function dataPixs () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -103,7 +102,7 @@ public function dataFormats () : array { $amount = $faker->randomFloat(2, 1, 999); $processedAt = $faker->dateTimeBetween('-1 week', '+1 week'); - $refund = $this->_getRefund($faker); + $refund = static::_getRefund($faker); $pix = new Pix(); @@ -126,7 +125,7 @@ public function dataFormats () : array * @param \Faker\Generator $faker * @return Refund */ - private function _getRefund ( $faker ) : Refund + private static function _getRefund ( $faker ) : Refund { return (new Refund()) ->setId($faker->regexify('[0-9A-Za-z]{25}')) diff --git a/tests/Api/Payloads/Entities/RefundTest.php b/tests/Api/Payloads/Entities/RefundTest.php index 571d492..cab43e8 100644 --- a/tests/Api/Payloads/Entities/RefundTest.php +++ b/tests/Api/Payloads/Entities/RefundTest.php @@ -2,35 +2,35 @@ namespace Piggly\Tests\Pix\Api\Entities; use DateTime; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Piggly\Pix\Api\Payloads\Entities\Refund; use Piggly\Pix\Exceptions\InvalidFieldException; -/** - * @coversDefaultClass \Piggly\Pix\Api\Payloads\Entities\Refund - */ +#[CoversClass(Refund::class)] class RefundTest extends TestCase { /** * Assert if $payload is equals to $obj exported. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * * @covers ::import * @covers ::export - * @dataProvider dataRefunds - * @test Expecting positive assertion. * @param array $payload * @param Refund $obj * @return void */ + #[Test, DataProvider('dataRefunds')] public function isMatching ( array $payload, Refund $obj ) { $this->assertEquals($payload, $obj->export()); } /** * Assert if $actual is equals to $expected. - * + * * Anytime it runs will create 100 random unique * payloads. It must assert all anytime. * @@ -40,25 +40,24 @@ public function isMatching ( array $payload, Refund $obj ) * @covers ::getAmount * @covers ::getRequestedAt * @covers ::getPaidAt - * @dataProvider dataFormats - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $actual * @return void */ + #[Test, DataProvider('dataFormats')] public function isMatchingFormat ( $expected, $actual ) { $this->assertEquals($expected, $actual); } /** * Assert if throw an exception. * - * @covers ::setStatus - * @test Expecting positive assertion. + * @covers ::__construct * @return void */ + #[Test] public function throwStatusException () - { - $this->expectException(InvalidFieldException::class); + { + $this->expectException(InvalidFieldException::class); (new Refund())->setStatus('unknown'); } @@ -68,7 +67,7 @@ public function throwStatusException () * Generated by fakerphp. * @return array */ - public function dataRefunds () : array + public static function dataRefunds () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -86,15 +85,15 @@ public function dataRefunds () : array { $payload['motivo'] = $faker->sentence(3); } if ( $faker->boolean() ) - { - $payload['horario'] = []; + { + $payload['horario'] = []; if ( $faker->boolean() ) { $payload['horario']['solicitacao'] = $faker->dateTimeBetween('-1 week', '+1 week')->format(DateTime::RFC3339); } if ( $faker->boolean() ) { $payload['horario']['liquidacao'] = $faker->dateTimeBetween('-1 week', '+1 week')->format(DateTime::RFC3339); } - + if ( empty($payload['horario']) ) { unset($payload['horario']); } } @@ -111,7 +110,7 @@ public function dataRefunds () : array * Generated by fakerphp. * @return array */ - public function dataFormats () : array + public static function dataFormats () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); diff --git a/tests/DynamicPayloadCreationTest.php b/tests/DynamicPayloadCreationTest.php index eaac03a..b3362a2 100644 --- a/tests/DynamicPayloadCreationTest.php +++ b/tests/DynamicPayloadCreationTest.php @@ -1,24 +1,25 @@ assertEquals($expected, $this->getData($reader, $type)); + $this->assertEquals($expected, $this->getData($reader, $type)); } /** @@ -57,7 +57,7 @@ public function isMatching ( string $type, $expected, string $pixCode ) * Generated by fakerphp. * @return array */ - public function dataPix () : array + public static function dataPix () : array { $arr = []; @@ -67,13 +67,13 @@ public function dataPix () : array { $pix = new DynamicPayload(); - // URL - $pixData['URL'] = $faker->url(); + // URL + $pixData['URL'] = $faker->url(); $pix->setUrl($pixData['URL']); // Merchant data - $pixData['MERCHANT_NAME'] = $faker->firstName().' '.$faker->lastName(); - $pixData['MERCHANT_CITY'] = $faker->city(); + $pixData['MERCHANT_NAME'] = $faker->firstName().' '.$faker->lastName(); + $pixData['MERCHANT_CITY'] = $faker->city(); $pix->setMerchantCity($pixData['MERCHANT_CITY'])->setMerchantName($pixData['MERCHANT_NAME']); // Pix Code @@ -109,11 +109,11 @@ private function getData ( Reader $reader, string $type ) /** * Get random pix key. - * + * * @param Faker $faker * @return array */ - protected function getRandomKey ( $faker ) : array + protected function getRandomKey ( $faker ) : array { $num = $faker->numberBetween(0, 4); @@ -150,7 +150,7 @@ protected function replacesChar ( ?string $str ) : ?string return $str; } - + /** * Generate random uuidv4. * diff --git a/tests/Emv/AbstractFieldTest.php b/tests/Emv/AbstractFieldTest.php index 7a74c48..d31f681 100644 --- a/tests/Emv/AbstractFieldTest.php +++ b/tests/Emv/AbstractFieldTest.php @@ -1,42 +1,40 @@ assertEquals($code, $obj->export()); } /** * Assert if throw an exception. * - * @covers ::required - * @covers ::export - * @test Expecting positive assertion. * @return void */ + #[Test] public function throwRequiredException () - { - $this->expectException(InvalidEmvFieldException::class); + { + $this->expectException(InvalidEmvFieldException::class); (new Field())->required(true)->export(); } @@ -46,7 +44,7 @@ public function throwRequiredException () * Generated by fakerphp. * @return array */ - public function dataFields () : array + public static function dataFields () : array { $arr = []; $faker = \Faker\Factory::create('pt_BR'); @@ -66,7 +64,7 @@ public function dataFields () : array $len = $faker->boolean() ? $size : $faker->numberBetween(0,99); $value = $faker->regexify('[0-9A-Za-z]{'.$size.'}'); $field->setValue($value); - + $size = \str_pad( $size, 2, '0', STR_PAD_LEFT ); $value = $len > $size ? \substr($value,0,$size) : $value; $arr[] = [ $id.$size.$value, $field ]; diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 28f7fee..cca2892 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -2,12 +2,13 @@ namespace Piggly\Tests\Pix; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Piggly\Pix\Parser; -/** - * @coversDefaultClass \Piggly\Pix\Parser - */ +#[CoversClass(Parser::class)] class ParserTest extends TestCase { /** @@ -15,12 +16,11 @@ class ParserTest extends TestCase * * @covers ::parseDocument * @covers ::validateDocument - * @dataProvider dataDocument - * @test Expecting positive assertion. * @param boolean $expected Expected result. * @param boolean $document Document to validate * @return boolean */ + #[Test, DataProvider('dataDocument')] public function canValidateDocument ( bool $expected, string $document ) { $this->assertEquals($expected, Parser::validateDocument($document)); } @@ -30,7 +30,7 @@ public function canValidateDocument ( bool $expected, string $document ) * Generated by fakerphp. * @return array */ - public function dataDocument () : array + public static function dataDocument () : array { return [ // Must match dataset @@ -447,12 +447,11 @@ public function dataDocument () : array * * @covers ::parseEmail * @covers ::validateEmail - * @dataProvider dataEmail - * @test Expecting positive assertion. * @param boolean $expected Expected result. * @param boolean $email Email to validate * @return boolean */ + #[DataProvider('dataEmail')] public function canValidateEmail ( bool $expected, string $email ) { $this->assertEquals($expected, Parser::validateEmail($email)); } @@ -462,7 +461,7 @@ public function canValidateEmail ( bool $expected, string $email ) * Generated by fakerphp. * @return array */ - public function dataEmail () : array + public static function dataEmail () : array { return [ // Must match dataset @@ -927,12 +926,11 @@ public function dataEmail () : array * * @covers ::parsePhone * @covers ::validatePhone - * @dataProvider dataPhone - * @test Expecting positive assertion. * @param boolean $expected Expected result. * @param boolean $phone Phone to validate * @return boolean */ + #[DataProvider('dataPhone')] public function canValidatePhone ( bool $expected, string $phone ) { $this->assertEquals($expected, Parser::validatePhone($phone)); } @@ -942,7 +940,7 @@ public function canValidatePhone ( bool $expected, string $phone ) * Generated by fakerphp. * @return array */ - public function dataPhone () : array + public static function dataPhone () : array { return [ // Must match dataset @@ -1351,17 +1349,16 @@ public function dataPhone () : array [false, '+553294-9192'], ]; } - + /** * Assert if $random is validated as $expected. * * @covers ::validateRandom - * @dataProvider dataRandom - * @test Expecting positive assertion. * @param boolean $expected Expected result. * @param boolean $random Random to validate * @return boolean */ + #[DataProvider('dataRandom')] public function canValidateRandom ( bool $expected, string $random ) { $this->assertEquals($expected, Parser::validateRandom($random)); } @@ -1371,7 +1368,7 @@ public function canValidateRandom ( bool $expected, string $random ) * Generated by fakerphp. * @return array */ - public function dataRandom () : array + public static function dataRandom () : array { return [ // Must match dataset @@ -1538,12 +1535,11 @@ public function dataRandom () : array * * @covers ::parseDocument * @covers ::getKeyType - * @dataProvider dataKeyType - * @test Expecting positive assertion. * @param string $expected Expected result. * @param string $data KeyType to validate * @return boolean */ + #[DataProvider('dataKeyType')] public function canGetKeyType ( string $expected, string $data ) { $this->assertEquals($expected, Parser::getKeyType($data)); } @@ -1553,7 +1549,7 @@ public function canGetKeyType ( string $expected, string $data ) * Generated by fakerphp. * @return array */ - public function dataKeyType () : array + public static function dataKeyType () : array { return [ // Must match dataset @@ -1859,20 +1855,19 @@ public function dataKeyType () : array ['random', 'd4ad12a4-cdf8-4e9d-be2a-61e2ea21bd75'], ]; } - + /** * Assert if $data is the $expected key type. * * @covers ::parseDocument * @covers ::getKeyType - * @dataProvider dataInvalidKeyType - * @test Expecting positive assertion. * @param string $data KeyType to validate * @return boolean */ + #[DataProvider('dataInvalidKeyType')] public function cannotGetKeyType ( string $data ) - { + { $this->expectException(Exception::class); Parser::getKeyType($data); } @@ -1883,7 +1878,7 @@ public function cannotGetKeyType ( string $data ) * Generated by fakerphp. * @return array */ - public function dataInvalidKeyType () : array + public static function dataInvalidKeyType () : array { return [ // Must not match dataset diff --git a/tests/QrCodeCreationTest.php b/tests/QrCodeCreationTest.php index f654666..1df7877 100644 --- a/tests/QrCodeCreationTest.php +++ b/tests/QrCodeCreationTest.php @@ -1,27 +1,25 @@ assertNotFalse(strpos($qrcode, 'data:image/svg+xml;base64')); } @@ -31,7 +29,7 @@ public function isMatching ( string $qrcode ) * Generated by fakerphp. * @return array */ - public function dataPix () : array + public static function dataPix () : array { $arr = []; @@ -40,7 +38,7 @@ public function dataPix () : array for ( $i = 0; $i < 20; $i++ ) { // Key - $key = $this->getRandomKey($faker); + $key = static::_getRandomKey($faker); // Payload $pix = new StaticPayload(); @@ -67,14 +65,14 @@ public function dataPix () : array return $arr; } - + /** * Get random pix key. - * + * * @param Faker $faker * @return array */ - protected function getRandomKey ( $faker ) : array + private static function _getRandomKey ( $faker ) : array { $num = $faker->numberBetween(0, 4); @@ -89,16 +87,16 @@ protected function getRandomKey ( $faker ) : array case 3: return ['KEY_TYPE' => Parser::KEY_TYPE_PHONE, 'KEY_VALUE' => $faker->phoneNumber()]; case 4: - return ['KEY_TYPE' => Parser::KEY_TYPE_RANDOM, 'KEY_VALUE' => $this->genUuid()]; + return ['KEY_TYPE' => Parser::KEY_TYPE_RANDOM, 'KEY_VALUE' => static::_genUuid()]; } } - + /** * Generate random uuidv4. * * @return void */ - protected function genUuid () + private static function _genUuid () { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" diff --git a/tests/ReaderTest.php b/tests/ReaderTest.php index 01b7e91..3bb3cdd 100644 --- a/tests/ReaderTest.php +++ b/tests/ReaderTest.php @@ -1,6 +1,9 @@ expectException(InvalidPixCodeException::class); @@ -26,19 +30,11 @@ public function isNotPixCodeValid () /** * Assert if $data matches with $expected. * - * @covers ::getPixKey - * @covers ::getKeyType - * @covers ::getDescription - * @covers ::getMerchantName - * @covers ::getMerchantCity - * @covers ::getAmount - * @covers ::export - * @dataProvider dataToMatch - * @test Expecting positive assertion. * @param mixed $expected * @param mixed $data * @return void */ + #[Test, DataProvider('dataToMatch')] public function isMatching ( $expected, $data ) { $this->assertEquals($expected, $data); } @@ -46,7 +42,7 @@ public function isMatching ( $expected, $data ) * Provider to isMatching() method. * @return array */ - public function dataToMatch () : array + public static function dataToMatch () : array { $pix_one = new Reader('00020101021126860014br.gov.bcb.pix0136285fb964-0087-4a94-851a-5a161ed8888a0224Solicitacao de pagamento52040000530398654041.005802BR5913STUDIO PIGGLY6007Uberaba62070503***63045C9B'); $pix_two = new Reader('00020101021126780014br.gov.bcb.pix0136285fb964-0087-4a94-851a-5a161ed8888a0216DS PIX PAGAMENTO52040000530398654041.005802BR5913STUDIO PIGGLY6007Uberaba62080504TX01630422D4'); diff --git a/tests/StaticPayloadCreationTest.php b/tests/StaticPayloadCreationTest.php index 5a814a4..10a157c 100644 --- a/tests/StaticPayloadCreationTest.php +++ b/tests/StaticPayloadCreationTest.php @@ -1,24 +1,25 @@ assertEquals($expected, $this->getData($reader, $type)); + $this->assertEquals($expected, $this->getData($reader, $type)); } /** @@ -57,7 +57,7 @@ public function isMatching ( string $type, $expected, string $pixCode ) * Generated by fakerphp. * @return array */ - public function dataPix () : array + public static function dataPix () : array { $arr = []; @@ -69,39 +69,39 @@ public function dataPix () : array $pixData = ['AMOUNT' => 0]; // Amount - if ( $faker->boolean() ) + if ( $faker->boolean() ) { $pixData['AMOUNT'] = $faker->randomFloat(2); $pix->setAmount($pixData['AMOUNT']); } // Key - $pixData = array_merge($pixData, $this->getRandomKey($faker)); + $pixData = array_merge($pixData, static::_getRandomKey($faker)); $pix->setPixKey($pixData['KEY_TYPE'], $pixData['KEY_VALUE']); // Description if ( $faker->boolean() ) - { - $pixData['DESC'] = $faker->words(3, true); + { + $pixData['DESC'] = $faker->words(3, true); $pix->setDescription($pixData['DESC']); } // Tid if ( $faker->boolean() ) - { - $pixData['TID'] = $faker->regexify('[A-Z]{2}[0-4]{8}'); + { + $pixData['TID'] = $faker->regexify('[A-Z]{2}[0-4]{8}'); $pix->setTid($pixData['TID']); } // Merchant data - $pixData['MERCHANT_NAME'] = $faker->firstName().' '.$faker->lastName(); - $pixData['MERCHANT_CITY'] = $faker->city(); + $pixData['MERCHANT_NAME'] = $faker->firstName().' '.$faker->lastName(); + $pixData['MERCHANT_CITY'] = $faker->city(); $pix->setMerchantCity($pixData['MERCHANT_CITY'])->setMerchantName($pixData['MERCHANT_NAME']); // Description if ( $faker->boolean() ) - { - $pixData['CEP'] = $faker->postcode(); + { + $pixData['CEP'] = $faker->postcode(); $pix->setPostalCode($pixData['CEP']); } @@ -153,11 +153,11 @@ private function getData ( Reader $reader, string $type ) /** * Get random pix key. - * + * * @param Faker $faker * @return array */ - protected function getRandomKey ( $faker ) : array + private static function _getRandomKey ( $faker ) : array { $num = $faker->numberBetween(0, 4); @@ -172,7 +172,7 @@ protected function getRandomKey ( $faker ) : array case 3: return ['KEY_TYPE' => Parser::KEY_TYPE_PHONE, 'KEY_VALUE' => $faker->phoneNumber()]; case 4: - return ['KEY_TYPE' => Parser::KEY_TYPE_RANDOM, 'KEY_VALUE' => $this->genUuid()]; + return ['KEY_TYPE' => Parser::KEY_TYPE_RANDOM, 'KEY_VALUE' => static::_genUuid()]; } } @@ -182,7 +182,7 @@ protected function getRandomKey ( $faker ) : array * @param string $str * @return string|null */ - protected function replacesChar ( ?string $str ) : ?string + private static function _replacesChar ( ?string $str ) : ?string { if ( \is_null($str) ) { return null; } @@ -194,13 +194,13 @@ protected function replacesChar ( ?string $str ) : ?string return $str; } - + /** * Generate random uuidv4. * * @return void */ - protected function genUuid () + private static function _genUuid () { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" diff --git a/tests/ValidStaticPixTest.php b/tests/ValidStaticPixTest.php index f4bd589..4347b69 100644 --- a/tests/ValidStaticPixTest.php +++ b/tests/ValidStaticPixTest.php @@ -1,66 +1,65 @@ getPixCode()), 0, \strlen($payload->getPixCode())-8); - $this->assertEquals($expected, $actual); + $this->assertEquals($expected, $actual); } - + /** * Assert if $expected matches to $actual CRC16. * * @covers MPM::CRC16 - * @dataProvider dataCRC - * @test Expecting positive assertion. * @param string $actual String to generate. * @return boolean */ + #[Test, DataProvider('dataCRC')] public function isCRCValid ( string $actual ) - { + { $expected = \substr($actual, -4); $actual = \str_replace($expected, '', $actual); - $this->assertEquals($expected, MPM::CRC16($actual)); + $this->assertEquals($expected, MPM::CRC16($actual)); } /** * A list with valid pix created. * Provider to isPixValid() method. - * + * * Please, add here only pix code generated * by bank applications. - * + * * @return array */ - public function dataPixes () : array + public static function dataPixes () : array { $pix = []; @@ -119,13 +118,13 @@ public function dataPixes () : array /** * A list with valid pix created to validate CRC. * Provider to isCRCValid() method. - * + * * Please, add here only pix code generated * by bank applications. - * + * * @return array */ - public function dataCRC () : array + public static function dataCRC () : array { $pix = []; From 0289eb32cc9ab2c80aed0918a9734f9bc0224b2d Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 09:28:39 -0300 Subject: [PATCH 3/8] :sparkles: feat(api-payload): Update all API payloads to new versions --- src/Api/Payloads/Cob.php | 348 ++++++++++++------ src/Api/Payloads/Entities/Amount.php | 31 +- src/Api/Payloads/Entities/Calendar.php | 93 ++--- .../Payloads/Entities/DueAmountModality.php | 130 +++---- src/Api/Payloads/Entities/Location.php | 64 ++-- src/Api/Payloads/Entities/Person.php | 191 +++++----- src/Api/Payloads/Entities/Pix.php | 116 ++++-- .../Payloads/Entities/PixComponentAmount.php | 288 +++++++++++++++ src/Api/Payloads/Entities/Refund.php | 234 ++++++++++-- src/Api/Payloads/Entities/RequestedRefund.php | 170 +++++++++ 10 files changed, 1239 insertions(+), 426 deletions(-) create mode 100644 src/Api/Payloads/Entities/PixComponentAmount.php create mode 100644 src/Api/Payloads/Entities/RequestedRefund.php diff --git a/src/Api/Payloads/Cob.php b/src/Api/Payloads/Cob.php index ebda71f..c3f7049 100644 --- a/src/Api/Payloads/Cob.php +++ b/src/Api/Payloads/Cob.php @@ -15,7 +15,7 @@ /** * Cob payload modeling. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads * @version 2.0.0 @@ -31,40 +31,40 @@ class Cob use UseExtra; /** - * Cob status as "NAO_SETADO" . - * + * Cob status as "NAO_SETADO" . + * * @var string * @since 2.0.0 */ const STATUS_UNSET = 'NAO_SETADO'; - + /** - * Cob status as "ATIVA" . - * + * Cob status as "ATIVA" . + * * @var string * @since 2.0.0 */ const STATUS_ACTIVE = 'ATIVA'; /** - * Cob status as "CONCLUIDA" . - * + * Cob status as "CONCLUIDA" . + * * @var string * @since 2.0.0 */ const STATUS_FINISHED = 'CONCLUIDA'; /** - * Cob status as "REMOVIDA_PELO_USUARIO_RECEBEDOR" . - * + * Cob status as "REMOVIDA_PELO_USUARIO_RECEBEDOR" . + * * @var string * @since 2.0.0 */ const STATUS_REMOVED_BY_RECEPTOR = 'REMOVIDA_PELO_USUARIO_RECEBEDOR'; /** - * Cob status as "REMOVIDA_PELO_PSP" . - * + * Cob status as "REMOVIDA_PELO_PSP" . + * * @var string * @since 2.0.0 */ @@ -72,7 +72,7 @@ class Cob /** * All cob status available. - * + * * @var array * @since 2.0.0 */ @@ -83,18 +83,18 @@ class Cob self::STATUS_REMOVED_BY_RECEPTOR, self::STATUS_REMOVED_BY_PSP ]; - + /** - * Cob type as "COB_IMMEDIATE". - * + * Cob type as "COB_IMMEDIATE". + * * @var string * @since 2.0.0 */ const TYPE_IMMEDIATE = 'COB_IMMEDIATE'; - + /** - * Cob type as "COB_DUE". - * + * Cob type as "COB_DUE". + * * @var string * @since 2.0.0 */ @@ -102,7 +102,7 @@ class Cob /** * All cob types available. - * + * * @var array * @since 2.0.0 */ @@ -113,121 +113,146 @@ class Cob /** * Receiver person. - * + * * @since 2.0.0 - * @var Person + * @var Person|null */ - protected $receiver; + protected $receiver = null; /** * Debtor person. - * + * * @since 2.0.0 - * @var Person + * @var Person|null */ - protected $debtor; + protected $debtor = null; /** * Calendar rules. - * + * * @since 2.0.0 - * @var Calendar + * @var Calendar|null */ - protected $calendar; + protected $calendar = null; /** * Amount rules. * @since 2.0.0 - * @var Amount + * @var Amount|null */ - protected $amount; + protected $amount = null; /** * Location data. - * + * * @since 2.0.0 - * @var Location + * @var Location|null */ - protected $location; + protected $location = null; /** * Pix data. - * + * * @since 2.0.0 - * @var Pix + * @var Pix|null + */ + protected $pix = null; + + /** + * Collection of pix related to cob. + * + * @since 3.0.0 + * @var array */ - protected $pix; + protected $pixes = []; /** * Pix key. * @since 2.0.0 - * @var string + * @var string|null + */ + protected $pixKey = null; + + /** + * Pix key. + * @since 2.0.0 + * @var string|null */ - protected $pixKey; + protected $pixCopyAndPast = null; /** * Pix key type. * @since 2.0.0 - * @var string + * @var string|null */ - protected $pixKeyType; + protected $pixKeyType = null; /** * Transaction id. * @since 2.0.0 - * @var string + * @var string|null */ - protected $tid; + protected $tid = null; /** * Request message to debtor. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $requestToDebtor; - + protected $requestToDebtor = null; + /** * Cob revision. - * + * * @since 2.0.0 - * @var int + * @var int|null */ - protected $revision; - + protected $revision = null; + /** * Cob status. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $status; + protected $status = null; /** * Set the cob receiver. * Will change $person type to Person::TYPE_RECEIVER. - * + * * @param Person $person * @since 2.0.0 + * @since 3.0.0 Clone person to avoid changes. * @return self */ public function setReceiver ( Person $person ) - { $this->receiver = $person->setType(Person::TYPE_RECEIVER); return $this; } + { + $new_person = new Person(Person::TYPE_RECEIVER, $person->getName(), $person->getDocument()); + $this->receiver = $new_person->import($person->export()); + return $this; + } /** * Set the cob debtor. * Will change $person type to Person::TYPE_DEBTOR. - * + * * @param Person $person * @since 2.0.0 + * @since 3.0.0 Clone person to avoid changes. * @return self */ public function setDebtor ( Person $person ) - { $this->debtor = $person->setType(Person::TYPE_DEBTOR); return $this; } + { + $new_person = new Person(Person::TYPE_DEBTOR, $person->getName(), $person->getDocument()); + $this->debtor = $new_person->import($person->export()); + return $this; + } /** * Set the cob calendar rules. - * + * * @param Calendar $calendar * @since 2.0.0 * @return self @@ -237,7 +262,7 @@ public function setCalendar ( Calendar $calendar ) /** * Set the cob amount rules. - * + * * @param Amount $amount * @since 2.0.0 * @return self @@ -247,7 +272,7 @@ public function setAmount ( Amount $amount ) /** * Set the cob location data. - * + * * @param Location $location * @since 2.0.0 * @return self @@ -257,7 +282,7 @@ public function setLocation ( Location $location ) /** * Set the cob pix data. - * + * * @param Pix $pix * @since 2.0.0 * @return self @@ -267,7 +292,7 @@ public function setPix ( Pix $pix ) /** * Set the cob pix key. - * + * * @param string $pixKey * @since 2.0.0 * @return self @@ -280,9 +305,23 @@ public function setPixKey ( string $pixKey ) return $this; } + /** + * Set the cob pix copy and past key. + * + * @param string $emv + * @since 3.0.0 + * @return self + * @throws CannotParseKeyTypeException Cannot parse type of pix key, may be invalid. + */ + public function setPixCopyPaste ( string $emv ) + { + $this->pixCopyAndPast = $emv; + return $this; + } + /** * Set the cob transaction id. - * + * * @param string $tid * @since 2.0.0 * @return self @@ -292,7 +331,7 @@ public function setTid ( string $tid ) /** * Set the cob request message to debtor. - * + * * @param string $requestToDebtor * @since 2.0.0 * @return self @@ -302,7 +341,7 @@ public function setRequestToDebtor ( string $requestToDebtor ) /** * Set the cob revision. - * + * * @param int $revision * @since 2.0.0 * @return self @@ -312,7 +351,7 @@ public function setRevision ( int $revision ) /** * Set the cob status. - * + * * @param string $status * @since 2.0.0 * @return self @@ -331,7 +370,7 @@ public function setStatus ( string $status ) /** * Get receiver to current cob. - * + * * @since 2.0.0 * @return Person|null */ @@ -340,7 +379,7 @@ public function getReceiver () : ?Person /** * Get debtor to current cob. - * + * * @since 2.0.0 * @return Person|null */ @@ -349,7 +388,7 @@ public function getDebtor () : ?Person /** * Get calendar to current cob. - * + * * @since 2.0.0 * @return Calendar|null */ @@ -358,7 +397,7 @@ public function getCalendar () : ?Calendar /** * Get amount to current cob. - * + * * @since 2.0.0 * @return Amount|null */ @@ -367,7 +406,7 @@ public function getAmount () : ?Amount /** * Get location to current cob. - * + * * @since 2.0.0 * @return Location|null */ @@ -376,7 +415,7 @@ public function getLocation () : ?Location /** * Get pix to current cob. - * + * * @since 2.0.0 * @return Pix|null */ @@ -385,7 +424,7 @@ public function getPix () : ?Pix /** * Get pix key to current cob. - * + * * @since 2.0.0 * @return string|null */ @@ -394,7 +433,7 @@ public function getPixKey () : ?string /** * Get pix key to current cob. - * + * * @since 2.0.0 * @return string|null */ @@ -403,7 +442,7 @@ public function getPixKeyType () : ?string /** * Get request message to debtor of current cob. - * + * * @since 2.0.0 * @return string|null */ @@ -412,7 +451,7 @@ public function getRequestToDebtor () : ?string /** * Get revision to current cob. - * + * * @since 2.0.0 * @return int|null */ @@ -421,7 +460,7 @@ public function getRevision () : ?int /** * Get status to current cob. - * + * * @since 2.0.0 * @return string|null */ @@ -430,20 +469,71 @@ public function getStatus () : ?string /** * Get tid to current cob. - * + * * @since 2.0.0 * @return string|null */ public function getTid () : ?string { return $this->tid; } + /** + * Add pix to cob. + * + * @param Pix|array $pix + * @since 3.0.0 + * @return self + */ + public function addPix ( $pix ) + { + $pix = $pix instanceof Pix ? $pix : (new Pix($pix['endToEndId'], $pix['valor']))->import($pix); + $this->pixes[$pix['endToEndId']] = $pix; + return $this; + } + + /** + * Get pix by e2eid. + * + * @param string $e2eid + * @since 3.0.0 + * @return Pix|null + */ + public function getPixBy ( string $e2eid ) : ?Pix + { return $this->pixes[$e2eid] ?? null; } + + /** + * Get all refunds associated to pix transaction. + * + * @since 3.0.0 + * @return array + */ + public function getPixes () : array + { return $this->pixes; } + + /** + * Is this cob paid? + * + * @since 3.0.0 + * @return bool + */ + public function isPaid () : bool + { + if ( static::isStatus(static::STATUS_FINISHED, $this->status) ) + { return true; } + + if ( empty($this->getPix()) === false ) { + return empty($this->getPix()->getE2eid()) === false; + } + + return false; + } + /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ - public function export () : array + public function export () : array { $array = []; @@ -469,15 +559,15 @@ public function export () : array { $array['revisao'] = $this->revision; } if ( !empty($this->extra) ) - { + { $array['infoAdicionais'] = []; foreach ( $this->extra as $name => $value ) - { + { $array['infoAdicionais'][] = [ 'nome' => $name, 'valor' => $value - ]; + ]; } } @@ -490,59 +580,79 @@ public function export () : array if ( isset($this->location) ) { $array['loc'] = $this->location->export(); } - if ( isset($this->pix) ) - { $array['pix'] = $this->pix->export(); } + if ( empty($this->pixes) === false ) + { + $array['pix'] = []; + + foreach ( $this->pixes as $pix ) + { $array['pix'][] = $pix->export(); } + } return $array; } /** * Import data from array. - * + * * @param array $response * @since 2.0.0 * @return self */ public function import ( array $response ) { - if ( isset($response['txid']) ) - { $this->setTid($response['txid']); } + // Base data + if ( empty($response['chave']) === false ) + { $this->setPixKey($response['chave']); } - if ( isset($response['revisao']) ) - { $this->setRevision(intval($response['revisao'])); } + if ( empty($response['pixCopiaECola']) === false ) + { $this->setPixKey($response['pixCopiaECola']); } - if ( isset($response['solicitacaoPagador']) ) + if ( empty($response['solicitacaoPagador']) === false ) { $this->setRequestToDebtor($response['solicitacaoPagador']); } - if ( isset($response['chave']) ) - { $this->setPixKey($response['chave']); } - - if ( isset($response['status']) ) - { $this->setStatus($response['status']); } - - if ( isset($response['infoAdicionais']) ) - { + if ( empty($response['infoAdicionais']) === false && \is_array($response['infoAdicionais']) ) + { foreach ( $response['infoAdicionais'] as $info ) { $this->addExtra($info['nome'], $info['valor']); } } - if ( isset($response['calendario']) ) + // Cob requested + if ( empty($response['calendario']) === false && \is_array($response['calendario']) ) { $this->setCalendar((new Calendar())->import($response['calendario'])); } - if ( isset($response['loc']) ) + if ( empty($response['devedor']) === false && \is_array($response['devedor']) ) + { $this->setDebtor((new Person(Person::TYPE_DEBTOR, $response['devedor']['name'], $response['devedor']['cpf'] ?? $response['devedor']['cnpj']))->import($response['devedor'])); } + + if ( empty($response['loc']) === false ) { $this->setLocation((new Location())->import($response['loc'])); } - if ( isset($response['devedor']) ) - { $this->setDebtor((new Person(Person::TYPE_DEBTOR))->import($response['devedor'])); } - - if ( isset($response['recebedor']) ) - { $this->setReceiver((new Person(Person::TYPE_RECEIVER))->import($response['recebedor'])); } - - if ( isset($response['valor']) ) + if ( empty($response['valor']) === false ) { $this->setAmount((new Amount())->import($response['valor'])); } - if ( isset($response['pix']) ) - { $this->setPix((new Pix())->import($response['pix'])); } + // Cob response + if ( empty($response['txid']) === false ) + { $this->setTid($response['txid']); } + + if ( empty($response['revisao']) === false ) + { $this->setRevision(\intval($response['revisao'])); } + + if ( empty($response['status']) === false ) + { $this->setStatus($response['status']); } + + if ( empty($response['recebedor']) === false && \is_array($response['recebedor']) ) + { $this->setReceiver((new Person(Person::TYPE_RECEIVER, $response['recebedor']['name'], $response['recebedor']['cpf'] ?? $response['recebedor']['cnpj']))->import($response['recebedor'])); } + + if ( empty($response['pix']) === false && \is_array($response['pix']) ) + { + $pixes = isset($response['pix'][0]) ? $response['pix'] : [$response['pix']]; + + foreach ( $pixes as $pix ) + { $this->addPix($pix); } + + if ( empty($this->pixes[0]) === false ) { + $this->setPix($this->pixes[0]); + } + } return $this; } @@ -571,14 +681,14 @@ public static function validateStatus ( string $status ) * @throws RuntimeException If some is a invalid status. */ public static function isStatus ( string $expected, string $actual ) : bool - { + { if ( \in_array($expected, static::STATUSES, true) === false ) { throw new RuntimeException(\sprintf('O status esperado deve ser um dos seguintes: `%s`.', \implode('`, `', static::STATUSES))); } - + if ( \in_array($actual, static::STATUSES, true) === false ) { throw new RuntimeException(\sprintf('O status atual deve ser um dos seguintes: `%s`.', \implode('`, `', static::STATUSES))); } - - return $expected === $actual; + + return $expected === $actual; } /** @@ -605,13 +715,13 @@ public static function validateType ( string $type ) * @throws RuntimeException If some is a invalid type. */ public static function isType ( string $expected, string $actual ) : bool - { + { if ( \in_array($expected, static::TYPES, true) === false ) { throw new RuntimeException(\sprintf('O tipo de cobrança esperado deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } - + if ( \in_array($actual, static::TYPES, true) === false ) { throw new RuntimeException(\sprintf('O tipo de cobrança atual deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } - - return $expected === $actual; + + return $expected === $actual; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Amount.php b/src/Api/Payloads/Entities/Amount.php index b78f7bd..8067113 100644 --- a/src/Api/Payloads/Entities/Amount.php +++ b/src/Api/Payloads/Entities/Amount.php @@ -3,7 +3,7 @@ /** * Amount entity to Cob payload. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -18,28 +18,28 @@ class Amount { /** * Original amount. - * + * * @since 2.0.0 - * @var float + * @var float|null */ - protected $original; + protected $original = null; /** * Final amount. - * + * * @since 2.0.0 - * @var float + * @var float|null */ - protected $final; + protected $final = null; /** * Modalities to amount. - * + * * @since 2.0.0 * @var array */ protected $modalities = []; - + /** * Get original amount. * @@ -58,7 +58,7 @@ public function getOriginal () : ?float */ public function setOriginal ( $original ) { $this->original = \is_float($original) ? $original : \floatval($original); return $this; } - + /** * Get final amount. * @@ -102,14 +102,14 @@ public function getModality ( string $modality ) : ?DueAmountModality * Get all modalities associated to pix transaction. * * @since 2.0.0 - * @return array + * @return array */ public function getModalities () : array { return $this->modalities; } /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ @@ -133,7 +133,7 @@ public function export () : array /** * Import data to array. - * + * * @param array $data * @since 2.0.0 * @return self @@ -147,16 +147,17 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) + if ( empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } foreach ( DueAmountModality::MODALITIES as $modality ) { - if ( isset($data[$modality]) ) + if ( empty($data[$modality]) === false ) { $this->addModality((new DueAmountModality($modality))->import($data[$modality])); } } + // @todo add retirada return $this; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Calendar.php b/src/Api/Payloads/Entities/Calendar.php index 43be593..ac3bf26 100644 --- a/src/Api/Payloads/Entities/Calendar.php +++ b/src/Api/Payloads/Entities/Calendar.php @@ -5,7 +5,7 @@ /** * Calendar entity to Cob payload. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -20,56 +20,57 @@ class Calendar { /** * Cob created at. - * + * * @since 2.0.0 - * @var DateTime + * @var DateTime|null */ - protected $createdAt; + protected $createdAt = null; /** * Cob presented at. - * + * * @since 2.0.0 - * @var DateTime + * @var DateTime|null */ - protected $presentedAt; + protected $presentedAt = null; /** * Cob expires after x seconds. - * + * * @since 2.0.0 - * @var int + * @var int|null */ - protected $expiresIn; + protected $expiresIn = null; /** * Cob due date. - * + * * @since 2.0.0 - * @var DateTime + * @var DateTime|null */ - protected $dueDate; + protected $dueDate = null; /** * Cob expires after x days. - * + * * @since 2.0.0 - * @var int + * @var int|null */ - protected $expirationAfter; - + protected $expirationAfter = null; + /** * Get date of creation to current calendar. - * + * * @since 2.0.0 - * @return DateTime + * @since 3.0.0 May return null value. + * @return DateTime|null */ - public function getCreatedAt () : DateTime + public function getCreatedAt () : ?DateTime { return $this->createdAt; } /** * Set created at to current calendar. - * + * * @param string|DateTime $createdAt * @since 2.0.0 * @return self @@ -79,16 +80,17 @@ public function setCreatedAt ( $createdAt ) /** * Get date of presentation to current calendar. - * + * * @since 2.0.0 - * @return DateTime + * @since 3.0.0 May return null value. + * @return DateTime|null */ - public function getPresentedAt () : DateTime + public function getPresentedAt () : ?DateTime { return $this->presentedAt; } /** * Set presented at to current calendar. - * + * * @param string|DateTime $presentedAt * @since 2.0.0 * @return self @@ -98,35 +100,37 @@ public function setPresentedAt ( $presentedAt ) /** * Get time to expires in seconds to current calendar. - * + * * @since 2.0.0 - * @return int + * @since 3.0.0 May return null value. + * @return int|null */ - public function getExpiresIn () : int + public function getExpiresIn () : ?int { return $this->expiresIn; } /** * Set time in seconds to expiration of current calendar. - * + * * @param int $seconds * @since 2.0.0 * @return self */ public function setExpiresIn ( int $seconds ) { $this->expiresIn = $seconds; return $this; } - + /** * Get due date to current calendar. - * + * * @since 2.0.0 - * @return DateTime + * @since 3.0.0 May return null value. + * @return DateTime|null */ - public function getDueDate () : DateTime + public function getDueDate () : ?DateTime { return $this->dueDate; } /** * Set due date to current calendar. - * + * * @param string|DateTime $dueDate * @since 2.0.0 * @return self @@ -136,16 +140,17 @@ public function setDueDate ( $dueDate ) /** * Get days after due date to expires to current calendar. - * + * * @since 2.0.0 - * @return int + * @since 3.0.0 May return null value. + * @return int|null */ - public function getExpirationAfter () : int + public function getExpirationAfter () : ?int { return $this->expirationAfter; } /** * Set time in days to expiration after due date of current calendar. - * + * * @param int $days * @since 2.0.0 * @return self @@ -155,20 +160,20 @@ public function setExpirationAfter ( int $days ) /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ public function export () : array { $array = []; - + if ( isset( $this->createdAt ) ) { $array['criacao'] = $this->createdAt->format(DateTime::RFC3339); } - + if ( isset( $this->presentedAt ) ) { $array['apresentacao'] = $this->presentedAt->format(DateTime::RFC3339); } - + if ( isset( $this->expiresIn ) ) { $array['expiracao'] = $this->expiresIn; } @@ -183,7 +188,7 @@ public function export () : array /** * Import data to array. - * + * * @param string $type Person type * @param array $data * @since 2.0.0 @@ -201,7 +206,7 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) + if ( empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } diff --git a/src/Api/Payloads/Entities/DueAmountModality.php b/src/Api/Payloads/Entities/DueAmountModality.php index be6b092..6160349 100644 --- a/src/Api/Payloads/Entities/DueAmountModality.php +++ b/src/Api/Payloads/Entities/DueAmountModality.php @@ -8,7 +8,7 @@ /** * Due amount modality entity to Cob payload. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -25,39 +25,39 @@ class DueAmountModality /** * Reduction modality. - * - * @var string + * + * @var string * @since 2.0.0 */ const MODALITY_REDUCTION = 'abatimento'; /** * Fee modality. - * - * @var string + * + * @var string * @since 2.0.0 */ const MODALITY_FEE = 'juros'; /** * Discount modality. - * - * @var string + * + * @var string * @since 2.0.0 */ const MODALITY_DISCOUNT = 'desconto'; /** * Bank fine modality. - * - * @var string + * + * @var string * @since 2.0.0 */ const MODALITY_BANKFINE = 'multa'; /** * All modalities available. - * + * * @var array * @since 2.0.0 */ @@ -70,23 +70,23 @@ class DueAmountModality /** * Reduction modality as fixed. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const REDUCTION_MODALITY_FIXED = 1; /** * Reduction modality as percentage. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const REDUCTION_MODALITY_PERCENTAGE = 2; /** * All reduction modalities available. - * + * * @var array * @since 2.0.0 */ @@ -94,71 +94,71 @@ class DueAmountModality /** * Fee modality as fixed by day. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_FIXED_REGULAR_CALENDAR = 1; /** * Fee modality as fixed by business day. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_FIXED_BUSINESS_CALENDAR = 5; /** * Fee modality as percentage by day at regular calendar. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_PERCENTAGE_BY_DAY_REGULAR_CALENDAR = 2; /** * Fee modality as percentage by mount at regular calendar. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_PERCENTAGE_BY_MONTH_REGULAR_CALENDAR = 3; /** * Fee modality as percentage by year at regular calendar. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_PERCENTAGE_BY_YEAR_REGULAR_CALENDAR = 4; /** * Fee modality as percentage by day at business calendar. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_PERCENTAGE_BY_DAY_BUSINESS_CALENDAR = 6; /** * Fee modality as percentage by mount at business calendar. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_PERCENTAGE_BY_MONTH_BUSINESS_CALENDAR = 7; /** * Fee modality as percentage by year at business calendar. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const FEE_MODALITY_PERCENTAGE_BY_YEAR_BUSINESS_CALENDAR = 8; /** * All fee modalities available. - * + * * @var array * @since 2.0.0 */ @@ -166,55 +166,55 @@ class DueAmountModality /** * Discount modality as fixed. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const DISCOUNT_MODALITY_FIXED = 1; /** * Discount modality as fixed by day. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const DISCOUNT_MODALITY_FIXED_REGULAR_CALENDAR = 3; /** * Discount modality as fixed by business day. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const DISCOUNT_MODALITY_FIXED_BUSINESS_CALENDAR = 4; /** * Discount modality as percentage. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const DISCOUNT_MODALITY_PERCENTAGE = 2; /** * Discount modality as percentage by day. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const DISCOUNT_MODALITY_PERCENTAGE_REGULAR_CALENDAR = 5; /** * Discount modality as percentage by business day. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const DISCOUNT_MODALITY_PERCENTAGE_BUSINESS_CALENDAR = 6; /** * All discount modalities available. - * + * * @var array * @since 2.0.0 */ @@ -222,23 +222,23 @@ class DueAmountModality /** * Bank fine modality as fixed. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const BANKFINE_MODALITY_FIXED = 1; /** * Bank fine modality as percentage. - * - * @var integer + * + * @var integer * @since 2.0.0 */ const BANKFINE_MODALITY_PERCENTAGE = 2; /** * All bank fine modalities available. - * + * * @var array * @since 2.0.0 */ @@ -270,8 +270,8 @@ class DueAmountModality /** * Create an amount modality. - * - * @param string $modality + * + * @param string $modality * @since 2.0.0 * @return self * @throws InvalidFieldException @@ -313,15 +313,15 @@ public function getId () : int * @return self * @throws InvalidFieldException */ - public function setId ( int $mid ) - { + public function setId ( int $mid ) + { try { static::validateId($this->modality, $mid); } catch ( Exception $e ) { throw new InvalidFieldException('Modalidade.Id', $mid, $e->getMessage()); } - $this->mid = $mid; - return $this; + $this->mid = $mid; + return $this; } /** @@ -345,7 +345,7 @@ public function setAmount ( $amount ) /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ @@ -363,7 +363,7 @@ public function export () : array /** * Import data to array. - * + * * @param array $data * @since 2.0.0 * @return self @@ -377,9 +377,9 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) - { - $this->{$method}($data[$field]); + if ( empty($data[$field]) === false ) + { + $this->{$method}($data[$field]); unset($data[$field]); } } @@ -448,13 +448,13 @@ public static function validateId ( string $modality, int $id ) * @throws RuntimeException If some is a invalid modality. */ public static function is ( string $expected, string $actual ) : bool - { + { if ( \in_array($expected, static::MODALITIES, true) === false ) { throw new RuntimeException(\sprintf('O tipo de modalidade esperado deve ser um dos seguintes: `%s`.', \implode('`, `', static::MODALITIES))); } - + if ( \in_array($actual, static::MODALITIES, true) === false ) { throw new RuntimeException(\sprintf('O tipo de modalidade atual deve ser um dos seguintes: `%s`.', \implode('`, `', static::MODALITIES))); } - - return $expected === $actual; + + return $expected === $actual; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Location.php b/src/Api/Payloads/Entities/Location.php index 06fafcf..5158113 100644 --- a/src/Api/Payloads/Entities/Location.php +++ b/src/Api/Payloads/Entities/Location.php @@ -8,7 +8,7 @@ /** * Location entity to Cob payload. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -23,51 +23,51 @@ class Location { /** * Location id. - * + * * @since 2.0.0 - * @var int + * @var int|null */ - protected $id; + protected $id = null; /** * Location transaction id. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $tid; + protected $tid = null; /** * Location url. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $location; + protected $location = null; /** * Location type. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $type; + protected $type = null; /** * Date when location was created. - * + * * @since 2.0.0 - * @var DateTime + * @var DateTime|null */ - protected $createdAt; + protected $createdAt = null; /** * Get date when location was created. * * @since 2.0.0 - * @return DateTime + * @return DateTime|null */ - public function getCreatedAt () : DateTime + public function getCreatedAt () : ?DateTime { return $this->createdAt; } /** @@ -84,9 +84,9 @@ public function setCreatedAt ( $createdAt ) * Get location type. * * @since 2.0.0 - * @return string + * @return string|null */ - public function getType () : string + public function getType () : ?string { return $this->type; } /** @@ -97,23 +97,23 @@ public function getType () : string * @return self */ public function setType ( string $type ) - { + { try { Cob::validateType($type); } catch ( Exception $e ) { throw new InvalidFieldException('Location.TipoCob', $type, $e->getMessage()); } - $this->type = $type; - return $this; + $this->type = $type; + return $this; } /** * Get location url. * * @since 2.0.0 - * @return string + * @return string|null */ - public function getLocation () : string + public function getLocation () : ?string { return $this->location; } /** @@ -130,7 +130,7 @@ public function setLocation ( string $location ) * Get location transaction id. * * @since 2.0.0 - * @return string + * @return string|null */ public function getTid () : ?string { return $this->tid; } @@ -149,9 +149,9 @@ public function setTid ( string $tid ) * Get location id. * * @since 2.0.0 - * @return int + * @return int|null */ - public function getId () : int + public function getId () : ?int { return $this->id; } /** @@ -166,14 +166,14 @@ public function setId ( int $id ) /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ public function export () : array { $array = []; - + if ( !\is_null($this->id) ) { $array['id'] = $this->id; } @@ -194,7 +194,7 @@ public function export () : array /** * Import data to array. - * + * * @param array $data * @since 2.0.0 * @return self @@ -211,7 +211,7 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) + if ( empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } diff --git a/src/Api/Payloads/Entities/Person.php b/src/Api/Payloads/Entities/Person.php index a78c2d3..ca06792 100644 --- a/src/Api/Payloads/Entities/Person.php +++ b/src/Api/Payloads/Entities/Person.php @@ -8,7 +8,7 @@ /** * Person entity to Cob payload. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -22,16 +22,16 @@ class Person { /** - * Person type as "recebedor" . - * + * Person type as "recebedor" . + * * @var string * @since 2.0.0 */ const TYPE_RECEIVER = 'recebedor'; - + /** - * Person type as "devedor" . - * + * Person type as "devedor" . + * * @var string * @since 2.0.0 */ @@ -39,7 +39,7 @@ class Person /** * All person types available. - * + * * @var array * @since 2.0.0 */ @@ -50,7 +50,7 @@ class Person /** * Person document. - * + * * @since 2.0.0 * @var string */ @@ -58,7 +58,7 @@ class Person /** * Person document type. - * + * * @since 2.0.0 * @var string */ @@ -66,7 +66,7 @@ class Person /** * Person name. - * + * * @since 2.0.0 * @var string */ @@ -74,55 +74,55 @@ class Person /** * Person fantasy name. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $fantasyName; - + protected $fantasyName = null; + /** * Person street address. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $streetAddress; - + protected $streetAddress = null; + /** * Person city. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $city; - + protected $city = null; + /** * Person state. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $state; - + protected $state = null; + /** * Person zip code. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $zipCode; - + protected $zipCode = null; + /** * Person email. - * + * * @since 2.0.0 - * @var string + * @var string|null */ - protected $email; - + protected $email = null; + /** * Person type. - * + * * @since 2.0.0 * @var string */ @@ -130,35 +130,38 @@ class Person /** * Create a person. - * - * @param string $type + * + * @param string $type * @since 2.0.0 + * @since 3.0.0 Expect name and document as param. * @return self */ - public function __construct ( string $type = self::TYPE_DEBTOR ) - { $this->setType($type); } + public function __construct ( string $type = self::TYPE_DEBTOR, string $name, string $document ) + { + $this->setType($type, $name, $document); + } /** * Get document to current person. - * + * * @since 2.0.0 * @return string */ - public function getDocument () : ?string + public function getDocument () : string { return $this->document; } /** * Get document type to current person. - * + * * @since 2.0.0 * @return string */ - public function getDocumentType () : ?string + public function getDocumentType () : string { return $this->documentType; } /** * Set CPF/CNPJ to current person. - * + * * @param string $document * @since 2.0.0 * @return self @@ -169,16 +172,16 @@ public function setDocument ( string $document ) $parsed = Parser::parseDocument($document); if ( Parser::validateCpf($parsed) ) - { - $this->document = $document; + { + $this->document = $document; $this->documentType = 'cpf'; - return $this; + return $this; } else if ( Parser::validateCnpj($parsed) ) - { - $this->document = $document; + { + $this->document = $document; $this->documentType = 'cnpj'; - return $this; + return $this; } throw new InvalidFieldException('Pessoa.Documento', $document, 'Nenhum CPF/CNPJ válido detectado.'); @@ -186,16 +189,16 @@ public function setDocument ( string $document ) /** * Get name to current person. - * + * * @since 2.0.0 * @return string */ - public function getName () : ?string + public function getName () : string { return $this->name; } /** * Set name to current person. - * + * * @param string $name * @since 2.0.0 * @return self @@ -205,16 +208,16 @@ public function setName ( string $name ) /** * Get fantasy name to current person. - * + * * @since 2.0.0 - * @return string + * @return string|null */ public function getFantasyName () : ?string { return $this->fantasyName; } /** * Set fantasy name to current person. - * + * * @param string $fantasyName * @since 2.0.0 * @return self @@ -224,16 +227,16 @@ public function setFantasyName ( string $fantasyName ) /** * Get street address to current person. - * + * * @since 2.0.0 - * @return string + * @return string|null */ public function getStreetAddress () : ?string { return $this->streetAddress; } /** * Set street address to current person. - * + * * @param string $streetAddress * @since 2.0.0 * @return self @@ -243,16 +246,16 @@ public function setStreetAddress ( string $streetAddress ) /** * Get city to current person. - * + * * @since 2.0.0 - * @return string + * @return string|null */ public function getCity () : ?string { return $this->city; } /** * Set city to current person. - * + * * @param string $city * @since 2.0.0 * @return self @@ -262,16 +265,16 @@ public function setCity ( string $city ) /** * Get state to current person. - * + * * @since 2.0.0 - * @return string + * @return string|null */ public function getState () : ?string { return $this->state; } /** * Set state to current person. - * + * * @param string $state * @since 2.0.0 * @return self @@ -287,16 +290,16 @@ public function setState ( string $state ) /** * Get zipcode to current person. - * + * * @since 2.0.0 - * @return string + * @return string|null */ public function getZipCode () : ?string { return $this->zipCode; } /** * Set zipcode to current person. - * + * * @param string $state * @since 2.0.0 * @return self @@ -308,22 +311,22 @@ public function setZipCode ( string $zipcode ) if ( strlen($_zipcode) > 8 ) { throw new InvalidFieldException('Pessoa.CEP', $zipcode, 'O CEP está inválido.'); } - $this->zipcode = \substr($_zipcode, 0, 5) . '-' . \substr($_zipcode, 5, 3); + $this->zipCode = \substr($_zipcode, 0, 5) . '-' . \substr($_zipcode, 5, 3); return $this; } /** * Get email to current person. - * + * * @since 2.0.0 - * @return string + * @return string|null */ public function getEmail () : ?string { return $this->email; } /** * Set email to current person. - * + * * @param string $state * @since 2.0.0 * @return self @@ -333,7 +336,7 @@ public function setEmail ( string $email ) /** * Get type to current person. - * + * * @since 2.0.0 * @return string */ @@ -342,12 +345,15 @@ public function getType () : string /** * Set type to current person. - * + * * @param string $type + * @param string|null $name + * @param string|null $document * @since 2.0.0 + * @since 3.0.0 Expect name and document as param. * @return self */ - public function setType ( string $type ) + public function setType (string $type, ?string $name = null, ?string $document = null) { try { static::validateType($type); } @@ -355,12 +361,16 @@ public function setType ( string $type ) { throw new InvalidFieldException('Pessoa.Tipo', $type, $e->getMessage()); } $this->type = $type; + + if (empty($name) === false) { $this->setName($name); } + if (empty($document) === false) { $this->setDocument($document);; } + return $this; } /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ @@ -370,25 +380,25 @@ public function export () : array if ( isset( $this->document ) ) { $array[$this->documentType] = $this->document; } - + if ( isset( $this->name ) ) { $array['nome'] = $this->name; } - + if ( isset( $this->fantasyName ) ) { $array['nomeFantasia'] = $this->fantasyName; } - + if ( isset( $this->city ) ) { $array['cidade'] = $this->city; } - + if ( isset( $this->state ) ) { $array['uf'] = $this->state; } - + if ( isset( $this->streetAddress ) ) { $array['logradouro'] = $this->streetAddress; } - + if ( isset( $this->zipCode ) ) { $array['cep'] = $this->zipCode; } - + if ( isset( $this->email ) ) { $array['email'] = $this->email; } @@ -397,7 +407,7 @@ public function export () : array /** * Import data to array. - * + * * @param string $type Person type * @param array $data * @since 2.0.0 @@ -406,10 +416,7 @@ public function export () : array public function import ( array $data ) { $importable = [ - 'nome' => 'setName', 'nomeFantasia' => 'setFantasyName', - 'cpf' => 'setDocument', - 'cnpj' => 'setDocument', 'logradouro' => 'setStreetAddress', 'cidade' => 'setCity', 'cep' => 'setZipCode', @@ -419,7 +426,7 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) + if ( empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } @@ -450,13 +457,13 @@ public static function validateType ( string $type ) * @throws RuntimeException If some is a invalid type. */ public static function isType ( string $expected, string $actual ) : bool - { + { if ( \in_array($expected, static::TYPES, true) === false ) { throw new RuntimeException(\sprintf('O tipo de pessoa esperado deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } - + if ( \in_array($actual, static::TYPES, true) === false ) { throw new RuntimeException(\sprintf('O tipo de pessoa atual deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } - - return $expected === $actual; + + return $expected === $actual; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Pix.php b/src/Api/Payloads/Entities/Pix.php index f686274..ad49dda 100644 --- a/src/Api/Payloads/Entities/Pix.php +++ b/src/Api/Payloads/Entities/Pix.php @@ -5,7 +5,7 @@ /** * Pix entity to Cob payload. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -25,23 +25,23 @@ class Pix * @since 2.0.0 */ protected $e2eid; - + /** - * Transaction id. + * Pix amount. * - * @var string + * @var float * @since 2.0.0 */ - protected $tid; - + protected $amount; + /** - * Pix amount. + * Transaction id. * - * @var float + * @var string|null * @since 2.0.0 */ - protected $amount; - + protected $tid; + /** * Pix processed date. * @@ -58,6 +58,15 @@ class Pix */ protected $info; + /** + * Components associated + * to Pix. + * + * @var array + * @since 3.0.0 + */ + protected $components = []; + /** * Refunds associated * to Pix. @@ -67,6 +76,20 @@ class Pix */ protected $refunds = []; + /** + * Create a new Pix entity. + * + * @param string $e2eid + * @param float|string $amount + * @since 3.0.0 + * @return self + */ + public function __construct ( string $e2eid, $amount ) + { + $this->setE2eid($e2eid); + $this->setAmount($amount); + } + /** * Get extra information. * @@ -90,9 +113,9 @@ public function setInfo ( string $info ) * Get pix processed date. * * @since 2.0.0 - * @return DateTime + * @return DateTime|null */ - public function getProcessedAt () : DateTime + public function getProcessedAt () : ?DateTime { return $this->processedAt; } /** @@ -128,7 +151,7 @@ public function setAmount ( $amount ) * Get transaction id. * * @since 2.0.0 - * @return string + * @return string|null */ public function getTid () : ?string { return $this->tid; } @@ -170,9 +193,9 @@ public function setE2eid ( string $e2eid ) * @return self */ public function addRefund ( $refund ) - { - $refund = $refund instanceof Refund ? $refund : (new Refund())->import($refund); - $this->refunds[$refund->getRid()] = $refund; + { + $refund = $refund instanceof Refund ? $refund : (new Refund($refund['id'], $refund['rtrId'], $refund['status'], $refund['valor']))->import($refund); + $this->refunds[$refund->getRid()] = $refund; return $this; } @@ -190,14 +213,48 @@ public function getRefund ( string $rid ) : ?Refund * Get all refunds associated to pix transaction. * * @since 2.0.0 - * @return array + * @return array */ public function getRefunds () : array { return $this->refunds; } + /** + * Add component to pix transacion. + * + * @param string $type + * @param PixComponentAmount|array $component + * @since 3.0.0 + * @return self + */ + public function addComponent ( string $type, $component ) + { + $component = $component instanceof PixComponentAmount ? $component : (new PixComponentAmount($type, $component['valor']))->import($component); + $this->components[$type] = $component; + return $this; + } + + /** + * Get component by type. + * + * @param string $rid + * @since 3.0.0 + * @return PixComponentAmount|null + */ + public function getComponent ( string $rid ) : ?PixComponentAmount + { return $this->components[$rid] ?? null; } + + /** + * Get all components associated to pix transaction. + * + * @since 3.0.0 + * @return array + */ + public function getComponents () : array + { return $this->components; } + /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ @@ -221,19 +278,26 @@ public function export () : array { $array['infoPagador'] = $this->info; } if ( !empty($this->refunds) ) - { + { $array['devolucoes'] = []; foreach ( $this->refunds as $r ) { $array['devolucoes'][] = $r->export(); } } + if ( !empty($this->components) ) { + $array['componentesValor'] = []; + + foreach ( $this->components as $c ) + { $array['componentesValor'][$c->getType()] = $c->export(); } + } + return $array; } /** * Import data to array. - * + * * @param array $data * @since 2.0.0 * @return self @@ -241,25 +305,29 @@ public function export () : array public function import ( array $data ) { $importable = [ - 'endToEndId' => 'setE2eid', 'txid' => 'setTid', - 'valor' => 'setAmount', 'horario' => 'setProcessedAt', 'infoPagador' => 'setInfo' ]; foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) + if ( empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } - if ( isset($data['devolucoes']) ) + if ( empty($data['devolucoes']) === false && \is_array($data['devolucoes']) ) { foreach ( $data['devolucoes'] as $devolucao ) { $this->addRefund($devolucao); } } + if ( empty($data['componentesValor']) === false && \is_array($data['componentesValor']) ) + { + foreach ( $data['componentesValor'] as $type => $componenteValor ) + { $this->addComponent($type, $componenteValor); } + } + return $this; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/PixComponentAmount.php b/src/Api/Payloads/Entities/PixComponentAmount.php new file mode 100644 index 0000000..d6ca8df --- /dev/null +++ b/src/Api/Payloads/Entities/PixComponentAmount.php @@ -0,0 +1,288 @@ + + * @author Piggly Lab + * @license MIT + * @copyright 2024 Piggly Lab + */ +class PixComponentAmount +{ + /** + * Component type as "original" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_ORIGINAL = 'original'; + + /** + * Component type as "saque" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_WITHDRAW = 'saque'; + + /** + * Component type as "juros" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_FEES = 'juros'; + + /** + * Component type as "multa" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_FINE = 'multa'; + + /** + * Component type as "abatimento" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_REBATE = 'abatimento'; + + /** + * Component type as "desconto" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_DISCOUNT = 'desconto'; + + /** + * All Component type available. + * + * @var array + * @since 3.0.0 + */ + const TYPES = [ + self::TYPE_ORIGINAL, + self::TYPE_WITHDRAW, + self::TYPE_FEES, + self::TYPE_FINE, + self::TYPE_REBATE, + self::TYPE_DISCOUNT + ]; + + /** + * Type. + * + * @since 3.0.0 + * @var float + */ + protected $type; + + /** + * Amount. + * + * @since 3.0.0 + * @var float + */ + protected $amount; + + /** + * Modality agent. + * + * @since 3.0.0 + * @var string|null + */ + protected $modalityAgent = null; + + /** + * Provider of withdrawal service. + * + * @since 3.0.0 + * @var string|null + */ + protected $providerOfWithdrawalService = null; + + /** + * Create a new Component entity. + * + * @param string $type + * @param float|string $amount + * @since 3.0.0 + * @return self + */ + public function __construct ( string $type, $amount ) + { + $this->setType($type); + $this->setAmount($amount); + } + + /** + * Get type. + * + * @since 3.0.0 + * @return string + */ + public function getType () : string + { return $this->type; } + + /** + * Set type. + * + * @param string $type Type. + * @since 3.0.0 + * @return self + * @throws RuntimeException If is a invalid type. + */ + public function setType ( string $type ) + { + static::validateType($type); + $this->type = $type; + return $this; + } + + /** + * Get original amount. + * + * @since 3.0.0 + * @return float + */ + public function getAmount () : float + { return $this->amount; } + + /** + * Set original amount. + * + * @param float|string $original Original amount. + * @since 3.0.0 + * @return self + */ + public function setAmount ( $original ) + { $this->amount = \is_float($original) ? $original : \floatval($original); return $this; } + + /** + * Get modality agent. + * + * @since 3.0.0 + * @return string|null + */ + public function getModalityAgent () : ?string + { return $this->modalityAgent; } + + /** + * Set modality agent. + * + * @param string $modalityAgent Original amount. + * @since 3.0.0 + * @return self + */ + public function setModalityAgent ( string $modalityAgent ) + { $this->modalityAgent = $modalityAgent; return $this; } + + /** + * Get provider of withdrawal service. + * + * @since 3.0.0 + * @return string|null + */ + public function getProviderOfWithdrawalService () : ?string + { return $this->providerOfWithdrawalService; } + + /** + * Set provider of withdrawal service. + * + * @param string $providerOfWithdrawalService Original amount. + * @since 3.0.0 + * @return self + */ + public function setProviderOfWithdrawalService ( string $providerOfWithdrawalService ) + { $this->providerOfWithdrawalService = $providerOfWithdrawalService; return $this; } + + /** + * Export this object to an array. + * + * @since 3.0.0 + * @return array + */ + public function export () : array + { + $array = [ + 'valor' => \number_format($this->amount, 2, '.', '') + ]; + + if ( !empty($this->modalityAgent) ) + { $array['modalidadeAgente'] = $this->modalityAgent; } + + if ( !empty($this->providerOfWithdrawalService) ) + { $array['prestadorDoServicoDeSaque'] = $this->providerOfWithdrawalService; } + + return $array; + } + + /** + * Import data to array. + * + * @param array $data + * @since 3.0.0 + * @return self + */ + public function import ( array $data ) + { + $importable = [ + 'modalidadeAgente' => 'setModalityAgent', + 'prestadorDoServicoDeSaque' => 'setProviderOfWithdrawalService' + ]; + + foreach ( $importable as $field => $method ) + { + if ( empty($data[$field]) === false ) + { $this->{$method}($data[$field]); } + } + + return $this; + } + + /** + * Throw an exception if $type is a invalid type. + * + * @param string $type + * @since 3.0.0 + * @return void + * @throws RuntimeException If is a invalid type. + */ + public static function validateType ( string $type ) + { + if ( \in_array($type, static::TYPES, true) === false ) + { throw new RuntimeException(\sprintf('O TIPO deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } + } + + /** + * Is $expected equal to $actual. + * + * @param string $expected + * @param string $actual + * @since 3.0.0 + * @return boolean + * @throws RuntimeException If some is a invalid TYPE. + */ + public static function isType ( string $expected, string $actual ) : bool + { + if ( \in_array($expected, static::TYPES, true) === false ) + { throw new RuntimeException(\sprintf('O TIPO esperado deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } + + if ( \in_array($actual, static::TYPES, true) === false ) + { throw new RuntimeException(\sprintf('O TIPO atual deve ser um dos seguintes: `%s`.', \implode('`, `', static::TYPES))); } + + return $expected === $actual; + } +} \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Refund.php b/src/Api/Payloads/Entities/Refund.php index 1d2e349..e321385 100644 --- a/src/Api/Payloads/Entities/Refund.php +++ b/src/Api/Payloads/Entities/Refund.php @@ -8,7 +8,7 @@ /** * Refund entity to Pix entity. - * + * * @package \Piggly\Pix * @subpackage \Piggly\Pix\Api\Payloads\Entities * @version 2.0.0 @@ -22,24 +22,24 @@ class Refund { /** - * Refund status as "EM_PROCESSAMENTO" . - * + * Refund status as "EM_PROCESSAMENTO" . + * * @var string * @since 2.0.0 */ const STATUS_PROCESSING = 'EM_PROCESSAMENTO'; - + /** - * Refund status as "DEVOLVIDO" . - * + * Refund status as "DEVOLVIDO" . + * * @var string * @since 2.0.0 */ const STATUS_CHARGEDBACK = 'DEVOLVIDO'; /** - * Refund status as "NAO_REALIZADO" . - * + * Refund status as "NAO_REALIZADO" . + * * @var string * @since 2.0.0 */ @@ -47,7 +47,7 @@ class Refund /** * All refund statuses available. - * + * * @var array * @since 2.0.0 */ @@ -57,6 +57,51 @@ class Refund self::STATUS_UNREALIZED ]; + /** + * Refund nature as "ORIGINAL" . + * + * @var string + * @since 3.0.0 + */ + const NATURE_ORIGINAL = 'ORIGINAL'; + + /** + * Refund nature as "RETIRADA" . + * + * @var string + * @since 3.0.0 + */ + const NATURE_RETIRADA = 'RETIRADA'; + + /** + * Refund nature as "MED_OPERACIONAL" . + * + * @var string + * @since 3.0.0 + */ + const NATURE_MED_OPERACIONAL = 'MED_OPERACIONAL'; + + /** + * Refund nature as "MED_FRAUDE" . + * + * @var string + * @since 3.0.0 + */ + const NATURE_MED_FRAUDE = 'MED_FRAUDE'; + + /** + * All refund natures available. + * + * @var array + * @since 3.0.0 + */ + const NATURES = [ + self::NATURE_ORIGINAL, + self::NATURE_RETIRADA, + self::NATURE_MED_OPERACIONAL, + self::NATURE_MED_FRAUDE + ]; + /** * ID created by client. * @@ -89,29 +134,63 @@ class Refund */ protected $status; + /** + * Return nature. + * + * @var string|null + * @since 3.0.0 + */ + protected $nature = null; + /** * Return reason. * - * @var string + * @var string|null * @since 2.0.0 */ - protected $reason; + protected $reason = null; + + /** + * Return description. + * + * @var string|null + * @since 3.0.0 + */ + protected $description = null; /** * Date when return was requested. * - * @var DateTime + * @var DateTime|null * @since 2.0.0 */ - protected $requestedAt; + protected $requestedAt = null; /** * Date when return was paid. * - * @var DateTime + * @var DateTime|null * @since 2.0.0 */ - protected $paidAt; + protected $paidAt = null; + + /** + * Create a new Refund entity. + * + * @param string $id + * @param string $rtid + * @param string $status + * @param float|string $amount + * @since 3.0.0 + * @return self + */ + public function __construct ( string $id, string $rtid, string $status, $amount ) + { + $this->setId($id); + $this->setRid($rtid); + $this->setStatus($status); + $this->setAmount($amount); + } /** * Get date when return was paid. @@ -151,6 +230,53 @@ public function getRequestedAt () : ?DateTime public function setRequestedAt ( $requestedAt ) { $this->requestedAt = $requestedAt instanceof DateTime ? $requestedAt : new DateTime($requestedAt); return $this; } + /** + * Get return nature. + * + * @since 3.0.0 + * @return string|null + */ + public function getNature () : ?string + { return $this->nature; } + + /** + * Set return nature. + * + * @param string $natureza Return nature. + * @since 3.0.0 + * @return self + * @throws InvalidFieldException + */ + public function setNature ( string $nature ) + { + try + { static::validateNature($nature); } + catch ( Exception $e ) + { throw new InvalidFieldException('Devolução.Natureza', $nature, $e->getMessage()); } + + $this->nature = $nature; + return $this; + } + + /** + * Get return description. + * + * @since 3.0.0 + * @return string|null + */ + public function getDescription () : ?string + { return $this->description; } + + /** + * Set return description. + * + * @param string $description Return description. + * @since 3.0.0 + * @return self + */ + public function setDescription ( string $description ) + { $this->description = $description; return $this; } + /** * Get return reason. * @@ -188,14 +314,14 @@ public function getStatus () : string * @throws InvalidFieldException */ public function setStatus ( string $status ) - { + { try { static::validateStatus($status); } catch ( Exception $e ) { throw new InvalidFieldException('Devolução.Status', $status, $e->getMessage()); } - - $this->status = $status; - return $this; + + $this->status = $status; + return $this; } /** @@ -257,14 +383,14 @@ public function setId ( string $id ) /** * Export this object to an array. - * + * * @since 2.0.0 * @return array */ public function export () : array { $array = []; - + if ( !empty($this->id) ) { $array['id'] = $this->id; } @@ -280,9 +406,15 @@ public function export () : array if ( !empty($this->reason) ) { $array['motivo'] = $this->reason; } + if ( !empty($this->description) ) + { $array['descricao'] = $this->description; } + + if ( !empty($this->nature) ) + { $array['natureza'] = $this->nature; } + if ( !empty($this->requestedAt) || !empty($this->paidAt) ) - { - $array['horario'] = []; + { + $array['horario'] = []; if ( !empty($this->requestedAt) ) { $array['horario']['solicitacao'] = $this->requestedAt->format(DateTime::RFC3339); } @@ -296,7 +428,7 @@ public function export () : array /** * Import data to array. - * + * * @param array $data * @since 2.0.0 * @return self @@ -304,16 +436,14 @@ public function export () : array public function import ( array $data ) { $importable = [ - 'id' => 'setId', - 'rtrId' => 'setRid', - 'valor' => 'setAmount', - 'status' => 'setStatus', - 'motivo' => 'setReason' + 'motivo' => 'setReason', + 'descricao' => 'setDescription', + 'natureza' => 'setNature' ]; foreach ( $importable as $field => $method ) { - if ( isset($data[$field]) ) + if ( empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } @@ -326,7 +456,7 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( isset($data['horario'][$field]) ) + if ( empty($data['horario'][$field]) === false ) { $this->{$method}($data['horario'][$field]); } } } @@ -358,13 +488,47 @@ public static function validateStatus ( string $status ) * @throws RuntimeException If some is a invalid status. */ public static function isStatus ( string $expected, string $actual ) : bool - { + { if ( \in_array($expected, static::STATUSES, true) === false ) { throw new RuntimeException(\sprintf('O status esperado deve ser um dos seguintes: `%s`.', \implode('`, `', static::STATUSES))); } - + if ( \in_array($actual, static::STATUSES, true) === false ) { throw new RuntimeException(\sprintf('O status atual deve ser um dos seguintes: `%s`.', \implode('`, `', static::STATUSES))); } - - return $expected === $actual; + + return $expected === $actual; + } + + /** + * Throw an exception if $nature is a invalid nature. + * + * @param string $nature + * @since 3.0.0 + * @return void + * @throws RuntimeException If is a invalid nature. + */ + public static function validateNature ( string $nature ) + { + if ( \in_array($nature, static::STATUSES, true) === false ) + { throw new RuntimeException(\sprintf('A natureza deve ser uma das seguintes: `%s`.', \implode('`, `', static::NATURES))); } + } + + /** + * Is $expected equal to $actual. + * + * @param string $expected + * @param string $actual + * @since 3.0.0 + * @return boolean + * @throws RuntimeException If some is a invalid nature. + */ + public static function isNature ( string $expected, string $actual ) : bool + { + if ( \in_array($expected, static::STATUSES, true) === false ) + { throw new RuntimeException(\sprintf('A natureza esperado deve ser uma das seguintes: `%s`.', \implode('`, `', static::NATURES))); } + + if ( \in_array($actual, static::STATUSES, true) === false ) + { throw new RuntimeException(\sprintf('A natureza atual deve ser uma das seguintes: `%s`.', \implode('`, `', static::NATURES))); } + + return $expected === $actual; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/RequestedRefund.php b/src/Api/Payloads/Entities/RequestedRefund.php new file mode 100644 index 0000000..79998dd --- /dev/null +++ b/src/Api/Payloads/Entities/RequestedRefund.php @@ -0,0 +1,170 @@ + + * @author Piggly Lab + * @license MIT + * @copyright 2024 Piggly Lab + */ +class RequestedRefund +{ + /** + * Return amount. + * + * @var float + * @since 3.0.0 + */ + protected $amount; + + /** + * Return nature. + * + * @var string|null + * @since 3.0.0 + */ + protected $nature = null; + + /** + * Return description. + * + * @var string|null + * @since 3.0.0 + */ + protected $description = null; + + /** + * Create a new Refund entity. + * + * @param float|string $amount + * @since 3.0.0 + * @return self + */ + public function __construct ( $amount ) + { + $this->setAmount($amount); + } + + /** + * Get return nature. + * + * @since 3.0.0 + * @return string|null + */ + public function getNature () : ?string + { return $this->nature; } + + /** + * Set return nature. + * + * @param string $natureza Return nature. + * @since 3.0.0 + * @return self + * @throws InvalidFieldException + */ + public function setNature ( string $nature ) + { + try + { Refund::validateNature($nature); } + catch ( Exception $e ) + { throw new InvalidFieldException('Devolução.Natureza', $nature, $e->getMessage()); } + + $this->nature = $nature; + return $this; + } + + /** + * Get return description. + * + * @since 3.0.0 + * @return string|null + */ + public function getDescription () : ?string + { return $this->description; } + + /** + * Set return description. + * + * @param string $description Return description. + * @since 3.0.0 + * @return self + */ + public function setDescription ( string $description ) + { $this->description = $description; return $this; } + + /** + * Get return amount. + * + * @since 3.0.0 + * @return float + */ + public function getAmount () : float + { return $this->amount; } + + /** + * Set return amount. + * + * @param float|string $amount Return amount. + * @since 3.0.0 + * @return self + */ + public function setAmount ( $amount ) + { $this->amount = \is_float($amount) ? $amount : \floatval($amount); return $this; } + + /** + * Export this object to an array. + * + * @since 3.0.0 + * @return array + */ + public function export () : array + { + $array = []; + + if ( !empty($this->amount) ) + { $array['valor'] = \number_format($this->amount, 2, '.', ''); } + + if ( !empty($this->description) ) + { $array['descricao'] = $this->description; } + + if ( !empty($this->nature) ) + { $array['natureza'] = $this->nature; } + + return $array; + } + + /** + * Import data to array. + * + * @param array $data + * @since 3.0.0 + * @return self + */ + public function import ( array $data ) + { + $importable = [ + 'descricao' => 'setDescription', + 'natureza' => 'setNature' + ]; + + foreach ( $importable as $field => $method ) + { + if ( empty($data[$field]) === false ) + { $this->{$method}($data[$field]); } + } + + return $this; + } +} \ No newline at end of file From 544e3e1cbc5b29d70db3b6adf47e72ed3910a35b Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 09:54:12 -0300 Subject: [PATCH 4/8] :rotating_light: test(global): Fix all tests according to payload changes --- src/Api/Payloads/Cob.php | 21 ++++++------ src/Api/Payloads/Entities/Location.php | 2 +- src/Api/Payloads/Entities/Person.php | 2 +- tests/Api/Payloads/CobTest.php | 40 ++++++++++++---------- tests/Api/Payloads/Entities/PersonTest.php | 16 +++++---- tests/Api/Payloads/Entities/PixTest.php | 16 ++++----- tests/Api/Payloads/Entities/RefundTest.php | 11 ++++-- 7 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/Api/Payloads/Cob.php b/src/Api/Payloads/Cob.php index c3f7049..3583222 100644 --- a/src/Api/Payloads/Cob.php +++ b/src/Api/Payloads/Cob.php @@ -162,7 +162,7 @@ class Cob * Collection of pix related to cob. * * @since 3.0.0 - * @var array + * @var array */ protected $pixes = []; @@ -288,7 +288,10 @@ public function setLocation ( Location $location ) * @return self */ public function setPix ( Pix $pix ) - { $this->pix = $pix; return $this; } + { + $this->pix = $pix; + \array_unshift($this->pixes, $pix); + } /** * Set the cob pix key. @@ -486,7 +489,7 @@ public function getTid () : ?string public function addPix ( $pix ) { $pix = $pix instanceof Pix ? $pix : (new Pix($pix['endToEndId'], $pix['valor']))->import($pix); - $this->pixes[$pix['endToEndId']] = $pix; + $this->pixes[$pix->getE2eid()] = $pix; return $this; } @@ -605,7 +608,7 @@ public function import ( array $response ) { $this->setPixKey($response['chave']); } if ( empty($response['pixCopiaECola']) === false ) - { $this->setPixKey($response['pixCopiaECola']); } + { $this->setPixCopyPaste($response['pixCopiaECola']); } if ( empty($response['solicitacaoPagador']) === false ) { $this->setRequestToDebtor($response['solicitacaoPagador']); } @@ -621,7 +624,7 @@ public function import ( array $response ) { $this->setCalendar((new Calendar())->import($response['calendario'])); } if ( empty($response['devedor']) === false && \is_array($response['devedor']) ) - { $this->setDebtor((new Person(Person::TYPE_DEBTOR, $response['devedor']['name'], $response['devedor']['cpf'] ?? $response['devedor']['cnpj']))->import($response['devedor'])); } + { $this->setDebtor((new Person(Person::TYPE_DEBTOR, $response['devedor']['nome'], $response['devedor']['cpf'] ?? $response['devedor']['cnpj']))->import($response['devedor'])); } if ( empty($response['loc']) === false ) { $this->setLocation((new Location())->import($response['loc'])); } @@ -633,14 +636,14 @@ public function import ( array $response ) if ( empty($response['txid']) === false ) { $this->setTid($response['txid']); } - if ( empty($response['revisao']) === false ) + if ( isset($response['revisao']) || empty($response['revisao']) === false ) { $this->setRevision(\intval($response['revisao'])); } if ( empty($response['status']) === false ) { $this->setStatus($response['status']); } if ( empty($response['recebedor']) === false && \is_array($response['recebedor']) ) - { $this->setReceiver((new Person(Person::TYPE_RECEIVER, $response['recebedor']['name'], $response['recebedor']['cpf'] ?? $response['recebedor']['cnpj']))->import($response['recebedor'])); } + { $this->setReceiver((new Person(Person::TYPE_RECEIVER, $response['recebedor']['nome'], $response['recebedor']['cpf'] ?? $response['recebedor']['cnpj']))->import($response['recebedor'])); } if ( empty($response['pix']) === false && \is_array($response['pix']) ) { @@ -648,10 +651,6 @@ public function import ( array $response ) foreach ( $pixes as $pix ) { $this->addPix($pix); } - - if ( empty($this->pixes[0]) === false ) { - $this->setPix($this->pixes[0]); - } } return $this; diff --git a/src/Api/Payloads/Entities/Location.php b/src/Api/Payloads/Entities/Location.php index 5158113..9b0b815 100644 --- a/src/Api/Payloads/Entities/Location.php +++ b/src/Api/Payloads/Entities/Location.php @@ -211,7 +211,7 @@ public function import ( array $data ) foreach ( $importable as $field => $method ) { - if ( empty($data[$field]) === false ) + if ( isset($data[$field]) || empty($data[$field]) === false ) { $this->{$method}($data[$field]); } } diff --git a/src/Api/Payloads/Entities/Person.php b/src/Api/Payloads/Entities/Person.php index ca06792..c9005f4 100644 --- a/src/Api/Payloads/Entities/Person.php +++ b/src/Api/Payloads/Entities/Person.php @@ -136,7 +136,7 @@ class Person * @since 3.0.0 Expect name and document as param. * @return self */ - public function __construct ( string $type = self::TYPE_DEBTOR, string $name, string $document ) + public function __construct ( string $type, string $name, string $document ) { $this->setType($type, $name, $document); } diff --git a/tests/Api/Payloads/CobTest.php b/tests/Api/Payloads/CobTest.php index f14326b..4ba0d6a 100644 --- a/tests/Api/Payloads/CobTest.php +++ b/tests/Api/Payloads/CobTest.php @@ -33,7 +33,12 @@ class CobTest extends TestCase */ #[Test, DataProvider('dataCobs')] public function isMatching ( array $payload, Cob $obj ) - { $this->assertEquals($payload, $obj->export()); } + { + if ( isset($payload['pix']) ) + { $payload['pix'] = [$payload['pix']]; } + + $this->assertEquals($payload, $obj->export()); + } /** * A bunch of pixs to import to Cob payload. @@ -46,7 +51,7 @@ public static function dataCobs () : array $arr = []; $faker = \Faker\Factory::create('pt_BR'); - for ( $i = 0; $i < 100; $i++ ) + for ( $i = 0; $i < 1; $i++ ) { $payload = []; $type = $faker->randomElement(Cob::TYPES); @@ -79,9 +84,7 @@ public static function dataCobs () : array else { $payload['loc'] = ['id' => 0]; } - if ( $faker->boolean() ) - { $payload['pix'] = static::_getPix($faker)->export(); } - + $payload['pix'] = static::_getPix($faker)->export(); $arr[] = [ $payload, (new Cob())->import($payload) ]; } @@ -96,9 +99,11 @@ public static function dataCobs () : array */ private static function _getPerson ( $faker ) : Person { - return (new Person()) - ->setDocument($faker->boolean() ? $faker->cpf() : $faker->cnpj()) - ->setName($faker->firstName().' '.$faker->lastName()); + return new Person( + Person::TYPE_DEBTOR, + $faker->firstName().' '.$faker->lastName(), + $faker->boolean() ? $faker->cpf() : $faker->cnpj() + ); } /** @@ -191,12 +196,8 @@ private static function _getModality ( $faker ) : DueAmountModality */ private static function _getPix ( $faker ) : Pix { - $pix = new Pix(); - - $pix - ->setE2eid($faker->regexify('[0-9A-Za-z]{25}')) - ->setAmount($faker->randomFloat(2, 1, 999)) - ->setProcessedAt(new DateTime()); + $pix = new Pix($faker->regexify('[0-9A-Za-z]{25}'), $faker->randomFloat(2, 1, 999)); + $pix->setProcessedAt(new DateTime()); if ( $faker->boolean() ) { @@ -217,11 +218,12 @@ private static function _getPix ( $faker ) : Pix */ private static function _getRefund ( $faker ) : Refund { - return (new Refund()) - ->setId($faker->regexify('[0-9A-Za-z]{25}')) - ->setRid($faker->regexify('[0-9A-Za-z]{25}')) - ->setAmount(\number_format($faker->randomFloat(2, 1, 999), 2, '.', '')) - ->setStatus($faker->randomElement(Refund::STATUSES)); + return new Refund( + $faker->regexify('[0-9A-Za-z]{25}'), + $faker->regexify('[0-9A-Za-z]{25}'), + $faker->randomElement(Refund::STATUSES), + \number_format($faker->randomFloat(2, 1, 999), 2, '.', '') + ); } /** diff --git a/tests/Api/Payloads/Entities/PersonTest.php b/tests/Api/Payloads/Entities/PersonTest.php index 36234f6..3cda24d 100644 --- a/tests/Api/Payloads/Entities/PersonTest.php +++ b/tests/Api/Payloads/Entities/PersonTest.php @@ -55,7 +55,9 @@ public static function dataPersons () : array for ( $i = 0; $i < 100; $i++ ) { - $payload = []; + $array = [ + 'nome' => $faker->firstName().' '.$faker->lastName() + ]; $array['cpf'] = $faker->cpf(); @@ -63,9 +65,6 @@ public static function dataPersons () : array if ( $faker->boolean() ) { $array['cnpj'] = $faker->cnpj(); unset($array['cpf']); } - if ( $faker->boolean() ) - { $array['nome'] = $faker->firstName().' '.$faker->lastName(); } - if ( $faker->boolean() ) { $array['nomeFantasia'] = $faker->company(); } @@ -84,7 +83,7 @@ public static function dataPersons () : array if ( $faker->boolean() ) { $array['email'] = $faker->email(); } - $arr[] = [ $payload, (new Person())->import($payload) ]; + $arr[] = [ $array, (new Person(Person::TYPE_DEBTOR, $array['nome'], $array['cpf'] ?? $array['cnpj']))->import($array) ]; } return $arr; @@ -111,8 +110,11 @@ public static function dataFormats () : array else { $doc = $faker->cnpj(); $docType = 'cnpj'; } - $person = new Person(); - $person->setDocument($doc); + $person = new Person( + Person::TYPE_DEBTOR, + $faker->firstName().' '.$faker->lastName(), + $doc + ); $arr[] = [ $docType, $person->getDocumentType() ]; } diff --git a/tests/Api/Payloads/Entities/PixTest.php b/tests/Api/Payloads/Entities/PixTest.php index b4b73fc..7acb999 100644 --- a/tests/Api/Payloads/Entities/PixTest.php +++ b/tests/Api/Payloads/Entities/PixTest.php @@ -81,7 +81,7 @@ public static function dataPixs () : array { $payload['devolucoes'][] = static::_getRefund($faker)->export(); } } - $arr[] = [ $payload, (new Pix())->import($payload) ]; + $arr[] = [ $payload, (new Pix($payload['endToEndId'], $payload['valor']))->import($payload) ]; } return $arr; @@ -104,10 +104,9 @@ public static function dataFormats () : array $processedAt = $faker->dateTimeBetween('-1 week', '+1 week'); $refund = static::_getRefund($faker); - $pix = new Pix(); + $pix = new Pix($faker->regexify('[0-9A-Za-z]{25}'), $amount); $pix - ->setAmount(\number_format($amount, 2, '.', '')) ->setProcessedAt($processedAt->format(DateTime::RFC3339)) ->addRefund($refund->export()); @@ -127,10 +126,11 @@ public static function dataFormats () : array */ private static function _getRefund ( $faker ) : Refund { - return (new Refund()) - ->setId($faker->regexify('[0-9A-Za-z]{25}')) - ->setRid($faker->regexify('[0-9A-Za-z]{25}')) - ->setAmount(\number_format($faker->randomFloat(2, 1, 999), 2, '.', '')) - ->setStatus($faker->randomElement(Refund::STATUSES)); + return new Refund( + $faker->regexify('[0-9A-Za-z]{25}'), + $faker->regexify('[0-9A-Za-z]{25}'), + $faker->randomElement(Refund::STATUSES), + \number_format($faker->randomFloat(2, 1, 999), 2, '.', '') + ); } } \ No newline at end of file diff --git a/tests/Api/Payloads/Entities/RefundTest.php b/tests/Api/Payloads/Entities/RefundTest.php index cab43e8..b0e684d 100644 --- a/tests/Api/Payloads/Entities/RefundTest.php +++ b/tests/Api/Payloads/Entities/RefundTest.php @@ -58,7 +58,7 @@ public function isMatchingFormat ( $expected, $actual ) public function throwStatusException () { $this->expectException(InvalidFieldException::class); - (new Refund())->setStatus('unknown'); + (new Refund('1', '2', Refund::STATUS_PROCESSING, 10))->setStatus('unknown'); } /** @@ -98,7 +98,7 @@ public static function dataRefunds () : array { unset($payload['horario']); } } - $arr[] = [ $payload, (new Refund())->import($payload) ]; + $arr[] = [ $payload, (new Refund($payload['id'], $payload['rtrId'], $payload['status'], $payload['valor']))->import($payload) ]; } return $arr; @@ -121,7 +121,12 @@ public static function dataFormats () : array $requestAt = $faker->dateTimeBetween('-1 week', '+1 week'); $paidAt = $faker->dateTimeBetween('-1 week', '+1 week'); - $refund = new Refund(); + $refund = new Refund( + $faker->regexify('[0-9A-Za-z]{25}'), + $faker->regexify('[0-9A-Za-z]{25}'), + $faker->randomElement(Refund::STATUSES), + $amount + ); $refund ->setAmount(\number_format($amount, 2, '.', '')) From d94e9a219a95bbac69868364ce1d883e4d3d716e Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 11:08:04 -0300 Subject: [PATCH 5/8] :sparkles: feat(mpm): Fix EMV fields size --- src/AbstractPayload.php | 63 +++++++++++++++++++++++++++++------------ src/Emv/MPM.php | 5 ++-- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/AbstractPayload.php b/src/AbstractPayload.php index 6b52115..cee1f1f 100644 --- a/src/AbstractPayload.php +++ b/src/AbstractPayload.php @@ -34,7 +34,7 @@ abstract class AbstractPayload /** * Create EMV MPM object. - * + * * @since 2.0.0 * @return void */ @@ -55,19 +55,36 @@ public function unsetPointOfInitiation () return $this; } + /** + * Set the current pix withdraw service facilitator. + * Max length 8 + * + * It will auto remove acents and auto + * cut to max length limit. + * + * @param string $service Pix withdraw service facilitator. + * @since 3.0.0 + * @return self + */ + public function setWithdrawServiceFacilitator ( string $service ) + { + $this->mpm->getEmv('26')->getField('05')->setValue(Cast::upperStr(Cast::cleanStr($service))); + return $this; + } + /** * Set the current pix merchant name. * Max length 25 - * + * * It will auto remove acents and auto * cut to max length limit. - * + * * @param string $merchantName Pix merchant name. * @since 2.0.0 * @return self */ public function setMerchantName ( string $merchantName ) - { + { $this->mpm->getEmv('59')->setValue(Cast::upperStr(Cast::cleanStr($merchantName))); return $this; } @@ -75,16 +92,16 @@ public function setMerchantName ( string $merchantName ) /** * Set the current pix merchant city. * Max length 15 - * + * * It will auto remove acents and auto * cut to max length limit. - * + * * @param string $merchantCity Pix merchant city. * @since 2.0.0 * @return self */ public function setMerchantCity ( string $merchantCity ) - { + { $this->mpm->getEmv('60')->setValue(Cast::upperStr(Cast::cleanStr($merchantCity))); return $this; } @@ -92,23 +109,23 @@ public function setMerchantCity ( string $merchantCity ) /** * Set the current pix postal code. * Max length 15 - * + * * It will auto remove acents and auto * cut to max length limit. - * + * * @param string $postalCode Pix postal code. * @since 2.0.0 * @return self */ public function setPostalCode ( string $postalCode ) - { + { $this->mpm->getEmv('61')->setValue(Cast::upperStr(Cast::cleanStr($postalCode), true)); return $this; } - + /** * Get the current pix code. - * + * * @param bool $regenerate * @since 2.0.0 * @return string @@ -116,11 +133,11 @@ public function setPostalCode ( string $postalCode ) */ public function getPixCode ( bool $regenerate = false ) : string { return $this->mpm->export($regenerate); } - + /** * Return the qr code based in current pix code. * The qr code format is a base64 image/png. - * + * * @param string $imageType Type of output image. * @param string $ecc QrCode ECC. * @since 2.0.0 @@ -129,7 +146,7 @@ public function getPixCode ( bool $regenerate = false ) : string * @throws QRCodeNotSupported QR Code is not supported. */ public function getQRCode ( string $imageType = QrCodeEnum::OUTPUT_SVG, int $ecc = QrCodeEnum::ECC_M ) : string - { + { if ( !self::supportQrCode() ) { throw new QRCodeNotSupported(); } @@ -138,7 +155,7 @@ public function getQRCode ( string $imageType = QrCodeEnum::OUTPUT_SVG, int $ecc 'outputType' => $imageType ]); - return (new QRCode($options))->render($this->getPixCode()); + return (new QRCode($options))->render($this->getPixCode()); } /** @@ -152,10 +169,20 @@ public function getMPM () : MPM /** * Return if php supports QR Code. - * + * * @since 2.0.0 * @return bool + * @deprecated 3.0.0 Use supportDependencies instead. */ public static function supportQrCode () : bool - { return ((float)phpversion('Core') >= 7.2) && (extension_loaded('gd') && function_exists('gd_info')); } + { return ((float)phpversion('Core') >= 8.0) && (extension_loaded('gd') && function_exists('gd_info')); } + + /** + * Return if php supports all dependencies. + * + * @since 3.0.0 + * @return bool + */ + public static function supportDependencies () : bool + { return ((float)phpversion('Core') >= 8.0) && (extension_loaded('gd') && function_exists('gd_info')) && (extension_loaded('mbstring') && function_exists('mb_substr')); } } \ No newline at end of file diff --git a/src/Emv/MPM.php b/src/Emv/MPM.php index 6d3844e..70d072d 100644 --- a/src/Emv/MPM.php +++ b/src/Emv/MPM.php @@ -56,9 +56,10 @@ public function __construct () ]; $this->emvs['26'] - ->addField(new Field('00', 'Globally Unique Identifier', 32, true, 'br.gov.bcb.pix')) + ->addField(new Field('00', 'Globally Unique Identifier', 14, true, 'br.gov.bcb.pix')) ->addField(new Field('01', 'Pix Key', 77, false)) - ->addField(new Field('02', 'Payment Description', 40, false)) + ->addField(new Field('02', 'Payment Description', 72, false)) + ->addField(new Field('05', 'Withdraw Service Facilitator', 8, false)) ->addField(new Field('25', 'Payment URL', 77, false)); $this->emvs['62'] From ab0848c668ba2593d7a7b56908537f5d37b2871f Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 11:24:41 -0300 Subject: [PATCH 6/8] :sparkles: feat(api-payloads): Add "retirada" to Amount --- src/Api/Payloads/Entities/Amount.php | 92 ++++++++++++++++++- .../Payloads/Entities/PixComponentAmount.php | 11 ++- 2 files changed, 99 insertions(+), 4 deletions(-) diff --git a/src/Api/Payloads/Entities/Amount.php b/src/Api/Payloads/Entities/Amount.php index 8067113..709810b 100644 --- a/src/Api/Payloads/Entities/Amount.php +++ b/src/Api/Payloads/Entities/Amount.php @@ -32,6 +32,14 @@ class Amount */ protected $final = null; + /** + * Capability of change amount in payer. + * + * @since 2.0.0 + * @var boolean + */ + protected $changeability = false; + /** * Modalities to amount. * @@ -40,6 +48,14 @@ class Amount */ protected $modalities = []; + /** + * Components associated to Pix. + * + * @var array + * @since 3.0.0 + */ + protected $withdraws = []; + /** * Get original amount. * @@ -107,6 +123,60 @@ public function getModality ( string $modality ) : ?DueAmountModality public function getModalities () : array { return $this->modalities; } + /** + * Get if payer can change amount. + * + * @since 3.0.0 + * @return bool + */ + public function getChangeability () : bool + { return $this->changeability; } + + /** + * Set if payer can change amount. + * + * @param bool $changeability + * @since 3.0.0 + * @return self + */ + public function payerCanChangeAmount ( bool $changeability ) + { $this->changeability = $changeability; return $this; } + + + /** + * Add component to pix transacion. + * + * @param string $type + * @param PixComponentAmount|array $component + * @since 3.0.0 + * @return self + */ + public function addWithdraw( string $type, $component ) + { + $component = $component instanceof PixComponentAmount ? $component : (new PixComponentAmount($type, $component['valor']))->import($component); + $this->withdraws[$type] = $component; + return $this; + } + + /** + * Get component by type. + * + * @param string $rid + * @since 3.0.0 + * @return PixComponentAmount|null + */ + public function getWithdraw( string $rid ) : ?PixComponentAmount + { return $this->withdraws[$rid] ?? null; } + + /** + * Get all components associated to pix transaction. + * + * @since 3.0.0 + * @return array + */ + public function getWithdraws() : array + { return $this->withdraws; } + /** * Export this object to an array. * @@ -116,7 +186,8 @@ public function getModalities () : array public function export () : array { $array = [ - 'original' => \number_format($this->original, 2, '.', '') + 'original' => \number_format($this->original, 2, '.', ''), + 'modalidadeAlteracao' => $this->changeability ? 1 : 0 ]; if ( !empty($this->final) ) @@ -128,6 +199,13 @@ public function export () : array { $array[$modality->getModality()] = $modality->export(); } } + if ( !empty($this->withdraws) ) { + $array['retirada'] = []; + + foreach ( $this->withdraws as $c ) + { $array['retirada'][$c->getType()] = $c->export(); } + } + return $array; } @@ -142,7 +220,7 @@ public function import ( array $data ) { $importable = [ 'original' => 'setOriginal', - 'final' => 'setFinal' + 'final' => 'setFinal', ]; foreach ( $importable as $field => $method ) @@ -151,13 +229,21 @@ public function import ( array $data ) { $this->{$method}($data[$field]); } } + if ( isset($data['modalidadeAlteracao']) ) + { $this->payerCanChangeAmount(\boolval($data['modalidadeAlteracao'])); } + foreach ( DueAmountModality::MODALITIES as $modality ) { if ( empty($data[$modality]) === false ) { $this->addModality((new DueAmountModality($modality))->import($data[$modality])); } } - // @todo add retirada + if ( empty($data['retirada']) === false && \is_array($data['retirada']) ) + { + foreach ( $data['retirada'] as $type => $componenteValor ) + { $this->addWithdraw($type, $componenteValor); } + } + return $this; } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/PixComponentAmount.php b/src/Api/Payloads/Entities/PixComponentAmount.php index d6ca8df..a53866a 100644 --- a/src/Api/Payloads/Entities/PixComponentAmount.php +++ b/src/Api/Payloads/Entities/PixComponentAmount.php @@ -66,6 +66,14 @@ class PixComponentAmount */ const TYPE_DISCOUNT = 'desconto'; + /** + * Component type as "troco" . + * + * @var string + * @since 3.0.0 + */ + const TYPE_EXCHANGE = 'troco'; + /** * All Component type available. * @@ -78,7 +86,8 @@ class PixComponentAmount self::TYPE_FEES, self::TYPE_FINE, self::TYPE_REBATE, - self::TYPE_DISCOUNT + self::TYPE_DISCOUNT, + self::TYPE_EXCHANGE ]; /** From b3c3c067b522f0dd51b04dbb528bf2099acace5e Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 11:49:05 -0300 Subject: [PATCH 7/8] :package: refactor(api-payloads): Helper functions --- src/Api/Payloads/Entities/Amount.php | 42 +++++++++------ src/Api/Payloads/Entities/Calendar.php | 24 ++++++--- .../Payloads/Entities/DueAmountModality.php | 30 ++++++----- src/Api/Payloads/Entities/Location.php | 25 ++++++--- src/Api/Payloads/Entities/Person.php | 25 ++++++--- src/Api/Payloads/Entities/Pix.php | 24 ++++++--- .../Payloads/Entities/PixComponentAmount.php | 25 ++++++--- src/Api/Payloads/Entities/Refund.php | 35 +++++++------ src/Api/Payloads/Entities/RequestedRefund.php | 28 ++++++---- src/Utils/Cast.php | 7 ++- src/Utils/Helper.php | 52 +++++++++++++++++++ 11 files changed, 220 insertions(+), 97 deletions(-) create mode 100644 src/Utils/Helper.php diff --git a/src/Api/Payloads/Entities/Amount.php b/src/Api/Payloads/Entities/Amount.php index 709810b..922f124 100644 --- a/src/Api/Payloads/Entities/Amount.php +++ b/src/Api/Payloads/Entities/Amount.php @@ -1,6 +1,8 @@ changeability = $changeability; return $this; } + public function payerCanChangeAmount ( $changeability ) + { $this->changeability = \boolval($changeability); return $this; } /** @@ -186,10 +188,12 @@ public function getWithdraws() : array public function export () : array { $array = [ - 'original' => \number_format($this->original, 2, '.', ''), - 'modalidadeAlteracao' => $this->changeability ? 1 : 0 + 'original' => \number_format($this->original, 2, '.', '') ]; + if ( $this->changeability ) + { $array['modalidadeAlteracao'] = 1; } + if ( !empty($this->final) ) { $array['final'] = \number_format($this->final, 2, '.', ''); } @@ -218,27 +222,22 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + Helper::fill($data, $this, [ 'original' => 'setOriginal', 'final' => 'setFinal', - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + 'modalidadeAlteracao' => 'payerCanChangeAmount' + ]); if ( isset($data['modalidadeAlteracao']) ) { $this->payerCanChangeAmount(\boolval($data['modalidadeAlteracao'])); } foreach ( DueAmountModality::MODALITIES as $modality ) { - if ( empty($data[$modality]) === false ) + if ( Helper::shouldBeArray($data[$modality] ?? null) ) { $this->addModality((new DueAmountModality($modality))->import($data[$modality])); } } - if ( empty($data['retirada']) === false && \is_array($data['retirada']) ) + if ( Helper::shouldBeArray($data['retirada'] ?? null) ) { foreach ( $data['retirada'] as $type => $componenteValor ) { $this->addWithdraw($type, $componenteValor); } @@ -246,4 +245,17 @@ public function import ( array $data ) return $this; } + + /** + * Create a new entity. + * + * @param array $data + * @since 3.0.0 + * @return Amount + */ + public static function create ( array $data ) + { + $e = new Amount(); + return $e->import($data); + } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Calendar.php b/src/Api/Payloads/Entities/Calendar.php index ac3bf26..3a74942 100644 --- a/src/Api/Payloads/Entities/Calendar.php +++ b/src/Api/Payloads/Entities/Calendar.php @@ -2,6 +2,7 @@ namespace Piggly\Pix\Api\Payloads\Entities; use DateTime; +use Piggly\Pix\Utils\Helper; /** * Calendar entity to Cob payload. @@ -196,20 +197,27 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + Helper::fill($data, $this, [ 'criacao' => 'setCreatedAt', 'apresentacao' => 'setPresentedAt', 'expiracao' => 'setExpiresIn', 'dataDeVencimento' => 'setDueDate', 'validadeAposVencimento' => 'setExpirationAfter' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); return $this; } + + /** + * Create a new entity. + * + * @param array $data + * @since 3.0.0 + * @return Calendar + */ + public static function create ( array $data ) + { + $e = new Calendar(); + return $e->import($data); + } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/DueAmountModality.php b/src/Api/Payloads/Entities/DueAmountModality.php index 6160349..8db1f0f 100644 --- a/src/Api/Payloads/Entities/DueAmountModality.php +++ b/src/Api/Payloads/Entities/DueAmountModality.php @@ -4,6 +4,7 @@ use Exception; use Piggly\Pix\Api\Payloads\Concerns\UseExtra; use Piggly\Pix\Exceptions\InvalidFieldException; +use Piggly\Pix\Utils\Helper; use RuntimeException; /** @@ -370,27 +371,32 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + $rest = Helper::fill($data, $this, [ 'modalidade' => 'setId', 'valorPerc' => 'setAmount' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { - $this->{$method}($data[$field]); - unset($data[$field]); - } - } + ]); // Import extra fields - foreach ( $data as $field => $value ) + foreach ( $rest as $field => $value ) { $this->addExtra($field, $value); } return $this; } + /** + * Create a new entity. + * + * @param string $modality + * @param array $data + * @since 3.0.0 + * @return DueAmountModality + */ + public static function create ( string $modality, array $data ) + { + $e = new DueAmountModality($modality); + return $e->import($data); + } + /** * Throw an exception if $modality is a invalid modality. * diff --git a/src/Api/Payloads/Entities/Location.php b/src/Api/Payloads/Entities/Location.php index 9b0b815..e91b03b 100644 --- a/src/Api/Payloads/Entities/Location.php +++ b/src/Api/Payloads/Entities/Location.php @@ -5,6 +5,7 @@ use Exception; use Piggly\Pix\Api\Payloads\Cob; use Piggly\Pix\Exceptions\InvalidFieldException; +use Piggly\Pix\Utils\Helper; /** * Location entity to Cob payload. @@ -201,20 +202,28 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + Helper::fill($data, $this, [ 'id' => 'setId', 'txid' => 'setTid', 'location' => 'setLocation', 'tipoCob' => 'setType', 'criacao' => 'setCreatedAt' - ]; - - foreach ( $importable as $field => $method ) - { - if ( isset($data[$field]) || empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); return $this; } + + /** + * Create a new entity. + * + * @param string $modality + * @param array $data + * @since 3.0.0 + * @return Location + */ + public static function create ( array $data ) + { + $e = new Location(); + return $e->import($data); + } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/Person.php b/src/Api/Payloads/Entities/Person.php index c9005f4..a76c527 100644 --- a/src/Api/Payloads/Entities/Person.php +++ b/src/Api/Payloads/Entities/Person.php @@ -4,6 +4,7 @@ use Exception; use Piggly\Pix\Exceptions\InvalidFieldException; use Piggly\Pix\Parser; +use Piggly\Pix\Utils\Helper; use RuntimeException; /** @@ -415,24 +416,32 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + Helper::fill($data, $this, [ 'nomeFantasia' => 'setFantasyName', 'logradouro' => 'setStreetAddress', 'cidade' => 'setCity', 'cep' => 'setZipCode', 'uf' => 'setState', 'email' => 'setEmail' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); return $this; } + /** + * Create a new entity. + * + * @param string $type + * @param array $data + * @since 3.0.0 + * @return Person + */ + public static function create ( string $type, array $data ) + { + $e = new Person($type, $data['name'], $data['cpf'] ?? $data['cnpj']); + return $e->import($data); + } + /** * Throw an exception if $type is a invalid type. * diff --git a/src/Api/Payloads/Entities/Pix.php b/src/Api/Payloads/Entities/Pix.php index ad49dda..4610114 100644 --- a/src/Api/Payloads/Entities/Pix.php +++ b/src/Api/Payloads/Entities/Pix.php @@ -2,6 +2,7 @@ namespace Piggly\Pix\Api\Payloads\Entities; use DateTime; +use Piggly\Pix\Utils\Helper; /** * Pix entity to Cob payload. @@ -304,17 +305,11 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + Helper::fill($data, $this, [ 'txid' => 'setTid', 'horario' => 'setProcessedAt', 'infoPagador' => 'setInfo' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); if ( empty($data['devolucoes']) === false && \is_array($data['devolucoes']) ) { @@ -330,4 +325,17 @@ public function import ( array $data ) return $this; } + + /** + * Create a new entity. + * + * @param array $data + * @since 3.0.0 + * @return Pix + */ + public static function create ( array $data ) + { + $e = new Pix($data['endToEndId'], $data['valor']); + return $e->import($data); + } } \ No newline at end of file diff --git a/src/Api/Payloads/Entities/PixComponentAmount.php b/src/Api/Payloads/Entities/PixComponentAmount.php index a53866a..a1b128f 100644 --- a/src/Api/Payloads/Entities/PixComponentAmount.php +++ b/src/Api/Payloads/Entities/PixComponentAmount.php @@ -1,6 +1,7 @@ 'setModalityAgent', 'prestadorDoServicoDeSaque' => 'setProviderOfWithdrawalService' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); return $this; } + /** + * Create a new entity. + * + * @param string $type + * @param array $data + * @since 3.0.0 + * @return PixComponentAmount + */ + public static function create ( string $type, array $data ) + { + $e = new PixComponentAmount($type, $data['valor']); + return $e->import($data); + } + /** * Throw an exception if $type is a invalid type. * diff --git a/src/Api/Payloads/Entities/Refund.php b/src/Api/Payloads/Entities/Refund.php index e321385..abe4844 100644 --- a/src/Api/Payloads/Entities/Refund.php +++ b/src/Api/Payloads/Entities/Refund.php @@ -4,6 +4,7 @@ use DateTime; use Exception; use Piggly\Pix\Exceptions\InvalidFieldException; +use Piggly\Pix\Utils\Helper; use RuntimeException; /** @@ -435,35 +436,37 @@ public function export () : array */ public function import ( array $data ) { - $importable = [ + Helper::fill($data, $this, [ 'motivo' => 'setReason', 'descricao' => 'setDescription', 'natureza' => 'setNature' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); if ( isset($data['horario']) ) { - $importable = [ + Helper::fill($data['horario'], $this, [ 'solicitacao' => 'setRequestedAt', 'liquidacao' => 'setPaidAt' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data['horario'][$field]) === false ) - { $this->{$method}($data['horario'][$field]); } - } + ]); } return $this; } + /** + * Create a new entity. + * + * @param string $type + * @param array $data + * @since 3.0.0 + * @return Refund + */ + public static function create ( array $data ) + { + $e = new Refund($data['id'], $data['rtrId'], $data['status'], $data['valor']); + return $e->import($data); + } + /** * Throw an exception if $status is a invalid status. * diff --git a/src/Api/Payloads/Entities/RequestedRefund.php b/src/Api/Payloads/Entities/RequestedRefund.php index 79998dd..43e50ec 100644 --- a/src/Api/Payloads/Entities/RequestedRefund.php +++ b/src/Api/Payloads/Entities/RequestedRefund.php @@ -1,10 +1,9 @@ 'setDescription', 'natureza' => 'setNature' - ]; - - foreach ( $importable as $field => $method ) - { - if ( empty($data[$field]) === false ) - { $this->{$method}($data[$field]); } - } + ]); return $this; } + + /** + * Create a new entity. + * + * @param string $type + * @param array $data + * @since 3.0.0 + * @return RequestedRefund + */ + public static function create ( array $data ) + { + $e = new RequestedRefund($data['valor']); + return $e->import($data); + } + } \ No newline at end of file diff --git a/src/Utils/Cast.php b/src/Utils/Cast.php index ffe14dc..c4a8d4f 100644 --- a/src/Utils/Cast.php +++ b/src/Utils/Cast.php @@ -1,12 +1,11 @@ + * @author Piggly Lab + * @license MIT + * @copyright 2024 Piggly Lab + */ +class Helper +{ + /** + * Mixed data should be an array. + * + * @param mixed $mixed + * @since 3.0.0 + * @return array + */ + public static function shouldBeArray ( $mixed ): bool + { + return empty($mixed) === false && \is_array($mixed); + } + + /** + * Fill class with data. + * + * @param array $data + * @param object $class + * @param array $methods + * @since 3.0.0 + * @return array Fields not filled. + */ + public static function fill(array $data, object $class, array $methods): array { + foreach ( $methods as $field => $method ) + { + if ( isset($data[$field]) || empty($data[$field]) === false ) + { + $class->{$method}($data[$field]); + unset($data[$field]); + } + } + + return $data; + } +} \ No newline at end of file From 73ef1f6fedf769f6be6c79e526beddcb7bab5121 Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 19 May 2024 12:08:17 -0300 Subject: [PATCH 8/8] :books: docs(readme): Version information --- CHANGELOG.md | 7 +++++++ README.md | 39 +++++++++++---------------------------- samples/payload.php | 24 ++++++++++++------------ samples/reader.php | 6 +++--- 4 files changed, 33 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f4539b..96fec64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 3.0.0 - `2024-05-19` + +* Não é mais compatível com PHP 7.x; +* Campos obrigatórios passaram para os construtores dos `Payloads`; +* Novos campos foram adicionados aos `Payloads` e `EMVs`; +* Demais métodos são compatíveis com a versão 2. + ## 2.0.2 - `2022-06-21` * O valor do Pix não é mais obrigatório no `StaticPayload`. diff --git a/README.md b/README.md index 52ed831..d4460a0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Latest Version on Packagist](https://img.shields.io/packagist/v/piggly/php-pix.svg?style=flat-square)](https://packagist.org/packages/piggly/php-pix) [![Packagist Downloads](https://img.shields.io/packagist/dt/piggly/php-pix?style=flat-square)](https://packagist.org/packages/piggly/php-pix) [![Packagist Stars](https://img.shields.io/packagist/stars/piggly/php-pix?style=flat-square)](https://packagist.org/packages/piggly/php-pix) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) ![PHP](https://img.shields.io/packagist/php-v/piggly/php-pix?style=flat-square) -![Versão Atual](https://img.shields.io/badge/version-2.x.x-green?style=flat-square) +![Versão Atual](https://img.shields.io/badge/version-3.x.x-green?style=flat-square) O **Pix** é o mais novo método de pagamento eletrônico criado pelo **Banco Central do Brasil**. Você encontra todos os detalhes na [página oficial](https://www.bcb.gov.br/estabilidadefinanceira/pix) do Pix. Saiba mais como ele funciona e como nossa biblioteca trabalha [clicando aqui](https://github.com/piggly-dev/php-pix/wiki/04.-Pix). @@ -19,34 +19,16 @@ Leia sobre a solução de problemas [clicando aqui](https://github.com/piggly-de > Se você apreciar a função desta biblioteca e quiser apoiar este trabalho, sinta-se livre para fazer qualquer doação para a chave aleatória Pix `aae2196f-5f93-46e4-89e6-73bf4138427b` ❤. -## Atualização para a versão 2.0.0 +## Atualização para a versão 3.0.0 -Muitas coisas mudaram, além do suporte ao **PHP 8** os campos EMV foram otimizados e expandidos. Além disso, as requisições para APIs foram removidas e os payloads para as APIs foram reformulados. Recomendamos ler a documentação de mudanças [clicando aqui](https://github.com/piggly-dev/php-pix/wiki/11.-Migrar-para-a-vers%C3%A3o-2.x.x) e verificar as diferenças. +A versão 3 é compatível com os métodos já utilizados na versão 2. Esteja atento as diferenças antes de atualizar: -A biblioteca `chillerlan/php-qrcode` não pode ser atualizada em `composer.json`, tornando necessário utilizar a `flag` `--ignore-platform-reqs` no **PHP 8**. Veja abaixo: +* Não é mais compatível com PHP 7.x; +* Campos obrigatórios passaram para os construtores dos `Payloads`; +* Novos campos foram adicionados aos `Payloads` e `EMVs`; +* Demais métodos são compatíveis com a versão 2. -```bash -# composer install -composer --ignore-platform-req=php install - -# composer update -composer --ignore-platform-req=php update - -# e todos os demais comandos do composer -``` - -> Muitos utilizadores dessa biblioteca ainda utilizando a versão `7.2` do PHP e não é o momento ideal para perder esse suporte. A partir da versão `2.1.x` pretendemores remover esse suporte. - -Para realizar as requisições da api, recomendamos a biblioteca [piggly/php-api-client](https://github.com/piggly-dev/php-api-client), ela foi desenvolvida para ser flexível e muito mais robusta que a solução anterior utilizada na versão 1.x.x. - -Veja as principais mudanças da versão 2.x.x: - -* O padrão EMV MPM foi atualizado e remodelado para suportar novos campos que podem ser utilizados nos Pix; -* A validação e verificação das chaves Pix foi aprimorada; -* A leitura de um código Pix resulta em um objeto de EMVs mais flexível; -* Os modificadores do payload foram removidos, sendo que agora, todos os dados preenchidos são automaticamente tratados e cortados respeitando completamente o padrão EMV; -* A classe `BaseAPI` foi removida, adotando como sugestão a biblioteca [piggly/php-api-client](https://github.com/piggly-dev/php-api-client) que traz muito mais flexibilidade e segurança; -* Os payloads para APIs foram remodelados para serem mais eficientes e flexíveis. +Para realizar as requisições da api, recomendamos a biblioteca [piggly/php-api-client](https://github.com/piggly-dev/php-api-client), ela foi desenvolvida para ser flexível e muito mais robusta que a solução anterior utilizada na versão 1.x.x. Mas você está livre para utilizar as libs que desejar. ## Instalação @@ -66,7 +48,8 @@ Veja as principais mudanças da versão 2.x.x: Essa bibliotecca possuí as seguintes dependências: * [Extensão GD do PHP](https://www.php.net/manual/pt_BR/book.image.php) para gerar QR Codes; -* PHP +7.2 ou PHP +8.0. +* [Extensão MBString do PHP](https://www.php.net/manual/pt_BR/mbstring.installation.php) para manipulação de strings; +* PHP +8.0. ## Como utilizar? @@ -146,4 +129,4 @@ Se você descobrir qualquer issue relacionada a segurança, por favor, envie um ## License -MIT License (MIT). Veja [LICENSE](LICENSE) para mais informações. \ No newline at end of file +MIT License (MIT). Veja [LICENSE](LICENSE) para mais informações. diff --git a/samples/payload.php b/samples/payload.php index 6245272..ce32dac 100644 --- a/samples/payload.php +++ b/samples/payload.php @@ -11,17 +11,17 @@ // Pix estático // Obtém os dados pix do usuário // -> Dados obrigatórios - $keyType = filter_input( INPUT_POST, 'keyType', FILTER_SANITIZE_STRING); - $keyValue = filter_input( INPUT_POST, 'keyValue', FILTER_SANITIZE_STRING); - $merchantName = filter_input( INPUT_POST, 'merchantName', FILTER_SANITIZE_STRING); - $merchantCity = filter_input( INPUT_POST, 'merchantCity', FILTER_SANITIZE_STRING); + $keyType = htmlspecialchars( filter_input( INPUT_POST, 'keyType' ) ); + $keyValue = htmlspecialchars( filter_input( INPUT_POST, 'keyValue' ) ); + $merchantName = htmlspecialchars( filter_input( INPUT_POST, 'merchantName' ) ); + $merchantCity = htmlspecialchars( filter_input( INPUT_POST, 'merchantCity' ) ); // -> Dados opcionais - $amount = filter_input( INPUT_POST, 'amount', FILTER_SANITIZE_STRING); - $tid = filter_input( INPUT_POST, 'tid', FILTER_SANITIZE_STRING); - $description = filter_input( INPUT_POST, 'description', FILTER_SANITIZE_STRING); + $amount = htmlspecialchars( filter_input( INPUT_POST, 'amount' ) ); + $tid = htmlspecialchars( filter_input( INPUT_POST, 'tid' ) ); + $description = htmlspecialchars( filter_input( INPUT_POST, 'description' ) ); - $payload = + $payload = (new StaticPayload()) ->setAmount($amount) ->setTid($tid) @@ -33,16 +33,16 @@ // Pix dinâmico // Obtém os dados pix do usuário // -> Dados obrigatórios - $merchantName = filter_input( INPUT_POST, 'merchantName', FILTER_SANITIZE_STRING); - $merchantCity = filter_input( INPUT_POST, 'merchantCity', FILTER_SANITIZE_STRING); + $merchantName = htmlspecialchars( filter_input( INPUT_POST, 'merchantName' ) ); + $merchantCity = htmlspecialchars( filter_input( INPUT_POST, 'merchantCity' ) ); // Obtém os dados do SPI para o Pix - $payload = + $payload = (new DynamicPayload()) ->setUrl($spiUrl) // URL do Pix no SPI ->setMerchantName($merchantName) ->setMerchantCity($merchantCity); - + // Continue o código // Código pix diff --git a/samples/reader.php b/samples/reader.php index 3145614..e79c11c 100644 --- a/samples/reader.php +++ b/samples/reader.php @@ -7,7 +7,7 @@ use Piggly\Pix\StaticPayload; // Obtém o código pix informado pelo usuário -$pixCode = filter_input( INPUT_POST, 'pixCode', FILTER_SANITIZE_STRING ); +$pixCode = htmlspecialchars(filter_input( INPUT_POST, 'pixCode' )); try { @@ -25,7 +25,7 @@ $payload = $reader->export(); /** @var StaticPayload Payload Pix manual */ - $payload = + $payload = (new StaticPayload()) // ->applyValidCharacters() // ->applyUppercase() @@ -38,7 +38,7 @@ ->setMerchantCity($merchantCity); // Continue o código - + // Código pix echo $pix->getPixCode(); // QR Code