From 5519ddcedcbb0c6525c4b65ac5f33536dad35f7a Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sat, 4 Apr 2020 18:21:22 +0200 Subject: [PATCH 01/87] config: first basic setup --- Dockerfile | 19 +++++++++++++++++++ Makefile | 5 +++++ README.md | 13 +++++++++++-- docker-compose.yml | 9 +++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..454d3f8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM php:7.4-cli + +RUN apt-get update && apt-get install --no-install-recommends -y \ + wget \ + vim \ + git \ + unzip + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +RUN mkdir -p /usr/src/app + +COPY composer.json /usr/src/app + +WORKDIR /usr/src/app + +RUN composer install --no-interaction + +CMD ["make"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cbe3da8 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +run: + docker-compose run --rm vending_machine bash + +phpunit: + ./vendor/bin/phpunit diff --git a/README.md b/README.md index 10eac5f..04ecd06 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ #Coding Dojo Silesia #3 ## Vending machine kata - PHP - Instructions: https://code.joejag.com/coding-dojo/vending-machine/ -Tests: `./bin/vendor/phpunit` \ No newline at end of file +Tests: `./vendor/bin/phpunit` + +## Setup +Run commands: +* `docker-compose up` + +## Run +Open interactive bash `docker-compose run --rm vending_machine bash` + +## Development +Copy dependencies form volume: `sudo docker cp vending_machine:/usr/src/app/vendor ./` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4af7020 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.7" +services: + vending_machine: + build: . + container_name: vending_machine + volumes: + - .:/usr/src/app + - /usr/src/app/vendor + command: ["make"] From 44f3c37e1bc2ee400048a061e513fe4609a42fca Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sat, 4 Apr 2020 21:47:26 +0200 Subject: [PATCH 02/87] config: setup coding standards --- Makefile | 15 +++++++++++++++ composer.json | 8 ++++++-- docker-compose.yml | 2 +- phpcs.xml | 6 ++++++ src/VendingMachine/VendingMachine.php | 1 - 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 phpcs.xml diff --git a/Makefile b/Makefile index cbe3da8..78ebebe 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,20 @@ +check: phpunit + run: docker-compose run --rm vending_machine bash +copy_vendor: + sudo docker cp vending_machine:/usr/src/app/vendor ./ + phpunit: ./vendor/bin/phpunit + +phpcs: + ./vendor/bin/phpcs --standard=PSR1 ./src + ./vendor/bin/phpcs --standard=PSR2 ./src + +phpstan: + ./vendor/bin/phpstan analyse src --level max + +php-cs-fixer: + ./vendor/bin/php-cs-fixer fix diff --git a/composer.json b/composer.json index dce098c..a8030b2 100644 --- a/composer.json +++ b/composer.json @@ -7,9 +7,13 @@ "email": "kontakt@dawidmazur.eu" } ], - "require": {}, + "require": { + }, "require-dev": { - "phpunit/phpunit": "^7" + "phpunit/phpunit": "^7", + "friendsofphp/php-cs-fixer": "^2.16", + "squizlabs/php_codesniffer": "^3.5", + "phpstan/phpstan": "^0.12.18" }, "autoload": { "psr-0": { diff --git a/docker-compose.yml b/docker-compose.yml index 4af7020..1439af8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,4 @@ services: volumes: - .:/usr/src/app - /usr/src/app/vendor - command: ["make"] + command: ["make", "check"] diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..1921c96 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,6 @@ + + + + src + + diff --git a/src/VendingMachine/VendingMachine.php b/src/VendingMachine/VendingMachine.php index 25f157d..1df3a91 100644 --- a/src/VendingMachine/VendingMachine.php +++ b/src/VendingMachine/VendingMachine.php @@ -5,7 +5,6 @@ namespace VendingMachine; final class VendingMachine { - function __construct() {} public function service(): string { From 5af90f1cba999d25fe72bf06f9b76ab3afba6e0c Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sat, 4 Apr 2020 21:53:52 +0200 Subject: [PATCH 03/87] config: add setup to php-cs-fixer --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 78ebebe..0bd398c 100644 --- a/Makefile +++ b/Makefile @@ -17,4 +17,4 @@ phpstan: ./vendor/bin/phpstan analyse src --level max php-cs-fixer: - ./vendor/bin/php-cs-fixer fix + ./vendor/bin/php-cs-fixer fix ./src --level=psr2 --dry-run From 27995efa4465a1bd0733b290ee0d79cfd3dc382d Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sat, 4 Apr 2020 22:07:37 +0200 Subject: [PATCH 04/87] config: fix php-cs-fixer --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0bd398c..cbb5212 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -check: phpunit +check: phpunit phpcs phpstan fix run: docker-compose run --rm vending_machine bash @@ -16,5 +16,5 @@ phpcs: phpstan: ./vendor/bin/phpstan analyse src --level max -php-cs-fixer: - ./vendor/bin/php-cs-fixer fix ./src --level=psr2 --dry-run +fix: + ./vendor/bin/php-cs-fixer fix ./src --dry-run From 5117fa1e237888d4645fc56777b43d5f788f505b Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sat, 4 Apr 2020 22:07:52 +0200 Subject: [PATCH 05/87] test: fix basic test --- src/VendingMachine/VendingMachine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VendingMachine/VendingMachine.php b/src/VendingMachine/VendingMachine.php index 1df3a91..d94c5f5 100644 --- a/src/VendingMachine/VendingMachine.php +++ b/src/VendingMachine/VendingMachine.php @@ -8,6 +8,6 @@ final class VendingMachine { public function service(): string { - return 'no service'; + return 'service'; } } From 47bbc1d015cffcfc4a43e4b298403221fe9bf11a Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sun, 5 Apr 2020 11:12:03 +0200 Subject: [PATCH 06/87] feat: add simple classes for commands, coins, change namespaces, --- composer.json | 5 +- composer.lock | 1744 ++++++++++++++++++- src/Command/BuyItemCommand.php | 20 + src/Command/Command.php | 8 + src/Factory/CommandFactory.php | 16 + src/Model/Coin.php | 10 + src/Model/Dime.php | 16 + src/Model/Dollar.php | 10 + src/Model/Item.php | 12 + src/Model/Money.php | 10 + src/Model/Nickel.php | 10 + src/Model/Quarter.php | 14 + src/Model/Value.php | 10 + src/{VendingMachine => }/VendingMachine.php | 4 +- src/prompt.php | 2 +- tests/Factory/CommandFactoryTest.php | 20 + tests/VendingMachine/VendingMachineTest.php | 12 +- 17 files changed, 1868 insertions(+), 55 deletions(-) create mode 100644 src/Command/BuyItemCommand.php create mode 100644 src/Command/Command.php create mode 100644 src/Factory/CommandFactory.php create mode 100644 src/Model/Coin.php create mode 100644 src/Model/Dime.php create mode 100644 src/Model/Dollar.php create mode 100644 src/Model/Item.php create mode 100644 src/Model/Money.php create mode 100644 src/Model/Nickel.php create mode 100644 src/Model/Quarter.php create mode 100644 src/Model/Value.php rename src/{VendingMachine => }/VendingMachine.php (58%) create mode 100644 tests/Factory/CommandFactoryTest.php diff --git a/composer.json b/composer.json index a8030b2..9d82286 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,9 @@ "phpstan/phpstan": "^0.12.18" }, "autoload": { - "psr-0": { - "VendingMachine": ["src", "tests"] + "psr-4": { + "VendingMachine\\": "src/", + "Tests\\": "tests/" } } } diff --git a/composer.lock b/composer.lock index 8d60c15..94d6ab7 100644 --- a/composer.lock +++ b/composer.lock @@ -1,13 +1,186 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "b4eb116a53958502052ba37cbec856fc", - "content-hash": "138b5fd9400b7504bc3755080c0051ec", + "content-hash": "206f42f23f49e7c8a36d1d1c136c0010", "packages": [], "packages-dev": [ + { + "name": "composer/semver", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.5 || ^5.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "time": "2020-01-13T12:06:48+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/1ab9842d69e64fb3a01be6b656501032d1b78cb7", + "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2020-03-01T12:26:26+00:00" + }, + { + "name": "doctrine/annotations", + "version": "1.10.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "5eb79f3dbdffed6544e1fc287572c0f462bd29bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5eb79f3dbdffed6544e1fc287572c0f462bd29bb", + "reference": "5eb79f3dbdffed6544e1fc287572c0f462bd29bb", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "ext-tokenizer": "*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2020-04-02T12:33:25+00:00" + }, { "name": "doctrine/instantiator", "version": "1.1.0", @@ -60,7 +233,158 @@ "constructor", "instantiate" ], - "time": "2017-07-22 11:58:36" + "time": "2017-07-22T11:58:36+00:00" + }, + { + "name": "doctrine/lexer", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "time": "2019-10-30T14:39:59+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.16.1", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02", + "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || ^7.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0 || ^5.0", + "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.2", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/traits": "^1.8", + "symfony/phpunit-bridge": "^4.3 || ^5.0", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz RumiƄski", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2019-11-25T22:10:32+00:00" }, { "name": "myclabs/deep-copy", @@ -108,7 +432,52 @@ "object", "object graph" ], - "time": "2018-06-11 23:09:50" + "time": "2018-06-11T23:09:50+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" }, { "name": "phar-io/manifest", @@ -163,7 +532,7 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-03-05 18:14:27" + "time": "2017-03-05T18:14:27+00:00" }, { "name": "phar-io/version", @@ -210,7 +579,58 @@ } ], "description": "Library for handling version information and constraints", - "time": "2017-03-05 17:38:23" + "time": "2017-03-05T17:38:23+00:00" + }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -264,7 +684,7 @@ "reflection", "static analysis" ], - "time": "2017-09-11 18:02:19" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -315,7 +735,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30 07:14:17" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -362,7 +782,7 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14 14:27:02" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", @@ -425,31 +845,273 @@ "spy", "stub" ], - "time": "2018-04-18 13:57:24" + "time": "2018-04-18T13:57:24+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "6.0.7", + "name": "phpstan/extension-installer", + "version": "1.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a" + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "2e041def501d661b806f50000c8a4dccbd4907b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/865662550c384bc1db7e51d29aeda1c2c161d69a", - "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/2e041def501d661b806f50000c8a4dccbd4907b4", + "reference": "2e041def501d661b806f50000c8a4dccbd4907b4", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", + "composer-plugin-api": "^1.1 || ^2.0", "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "consistence/coding-standard": "^3.8", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16", + "phpstan/phpstan-strict-rules": "^0.11", + "slevomat/coding-standard": "^5.0.4" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "time": "2020-03-31T16:00:42+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.12.18", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "1ce27fe29c8660a27926127d350d53d80c4d4286" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ce27fe29c8660a27926127d350d53d80c4d4286", + "reference": "1ce27fe29c8660a27926127d350d53d80c4d4286", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "time": "2020-03-22T16:51:47+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "0.12.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "51d21a83b97e539e1fc56c1ce42ac0f187407fb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/51d21a83b97e539e1fc56c1ce42ac0f187407fb6", + "reference": "51d21a83b97e539e1fc56c1ce42ac0f187407fb6", + "shasum": "" + }, + "require": { + "php": "~7.1", + "phpstan/phpstan": "^0.12" + }, + "require-dev": { + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "jakub-onderka/php-parallel-lint": "^1.0", + "localheinz/composer-normalize": "^1.3.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.5.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "time": "2020-01-12T16:25:40+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "0.12.6", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "26394996368b6d033d012547d3197f4e07e23021" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/26394996368b6d033d012547d3197f4e07e23021", + "reference": "26394996368b6d033d012547d3197f4e07e23021", + "shasum": "" + }, + "require": { + "php": "~7.1", + "phpstan/phpstan": "^0.12.4" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^7.0", + "satooshi/php-coveralls": "^1.0", + "slevomat/coding-standard": "^4.7.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "time": "2020-01-10T12:07:21+00:00" + }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "0.12.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "a670a59aff7cf96f75d21b974860ada10e25b2ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/a670a59aff7cf96f75d21b974860ada10e25b2ee", + "reference": "a670a59aff7cf96f75d21b974860ada10e25b2ee", + "shasum": "" + }, + "require": { + "php": "~7.1", + "phpstan/phpstan": "^0.12.6" + }, + "require-dev": { + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.5.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Extra strict and opinionated rules for PHPStan", + "time": "2020-01-20T13:08:52+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "6.0.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/865662550c384bc1db7e51d29aeda1c2c161d69a", + "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.1", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, @@ -488,7 +1150,7 @@ "testing", "xunit" ], - "time": "2018-06-01 07:51:50" + "time": "2018-06-01T07:51:50+00:00" }, { "name": "phpunit/php-file-iterator", @@ -535,7 +1197,7 @@ "filesystem", "iterator" ], - "time": "2018-06-11 11:44:00" + "time": "2018-06-11T11:44:00+00:00" }, { "name": "phpunit/php-text-template", @@ -576,7 +1238,7 @@ "keywords": [ "template" ], - "time": "2015-06-21 13:50:34" + "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", @@ -625,7 +1287,7 @@ "keywords": [ "timer" ], - "time": "2018-02-01 13:07:23" + "time": "2018-02-01T13:07:23+00:00" }, { "name": "phpunit/php-token-stream", @@ -674,7 +1336,7 @@ "keywords": [ "tokenizer" ], - "time": "2018-02-01 13:16:43" + "time": "2018-02-01T13:16:43+00:00" }, { "name": "phpunit/phpunit", @@ -758,7 +1420,149 @@ "testing", "xunit" ], - "time": "2018-06-21 13:13:39" + "time": "2018-06-21T13:13:39+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2020-03-23T09:12:05+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -803,7 +1607,7 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04 06:30:41" + "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", @@ -867,7 +1671,7 @@ "compare", "equality" ], - "time": "2018-06-14 15:05:28" + "time": "2018-06-14T15:05:28+00:00" }, { "name": "sebastian/diff", @@ -923,7 +1727,7 @@ "unidiff", "unified diff" ], - "time": "2018-06-10 07:54:39" + "time": "2018-06-10T07:54:39+00:00" }, { "name": "sebastian/environment", @@ -973,7 +1777,7 @@ "environment", "hhvm" ], - "time": "2017-07-01 08:51:00" + "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", @@ -1040,7 +1844,7 @@ "export", "exporter" ], - "time": "2017-04-03 13:19:02" + "time": "2017-04-03T13:19:02+00:00" }, { "name": "sebastian/global-state", @@ -1091,7 +1895,7 @@ "keywords": [ "global state" ], - "time": "2017-04-27 15:39:26" + "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", @@ -1138,7 +1942,7 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03 12:35:26" + "time": "2017-08-03T12:35:26+00:00" }, { "name": "sebastian/object-reflector", @@ -1183,7 +1987,7 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29 09:07:27" + "time": "2017-03-29T09:07:27+00:00" }, { "name": "sebastian/recursion-context", @@ -1236,7 +2040,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03 06:23:57" + "time": "2017-03-03T06:23:57+00:00" }, { "name": "sebastian/resource-operations", @@ -1278,7 +2082,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28 20:34:47" + "time": "2015-07-28T20:34:47+00:00" }, { "name": "sebastian/version", @@ -1321,7 +2125,861 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03 07:35:21" + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.4", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "dceec07328401de6211037abbb18bda423677e26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", + "reference": "dceec07328401de6211037abbb18bda423677e26", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-01-30T22:20:29+00:00" + }, + { + "name": "symfony/console", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", + "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/service-contracts": "^1.1|^2" + }, + "conflict": { + "symfony/dependency-injection": "<4.4", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2020-03-30T11:42:42+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/24f40d95385774ed5c71dbf014edd047e2f2f3dc", + "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "symfony/event-dispatcher-contracts": "^2" + }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^4.4|^5.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2020-03-27T16:56:45+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "af23c2584d4577d54661c434446fb8fbed6025dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/af23c2584d4577d54661c434446fb8fbed6025dd", + "reference": "af23c2584d4577d54661c434446fb8fbed6025dd", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-11-18T17:27:11+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "ca3b87dd09fff9b771731637f5379965fbfab420" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/ca3b87dd09fff9b771731637f5379965fbfab420", + "reference": "ca3b87dd09fff9b771731637f5379965fbfab420", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2020-03-27T16:56:45+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/600a52c29afc0d1caa74acbec8d3095ca7e9910d", + "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d", + "shasum": "" + }, + "require": { + "php": "^7.2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2020-03-27T16:56:45+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/09dccfffd24b311df7f184aa80ee7b61ad61ed8d", + "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d", + "shasum": "" + }, + "require": { + "php": "^7.2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2020-03-27T16:56:45+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "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" + ], + "time": "2020-02-27T09:26:54+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2020-03-09T19:04:49+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "2a18e37a489803559284416df58c71ccebe50bf0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/2a18e37a489803559284416df58c71ccebe50bf0", + "reference": "2a18e37a489803559284416df58c71ccebe50bf0", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-02-27T09:26:54+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "37b0976c78b94856543260ce09b460a7bc852747" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", + "reference": "37b0976c78b94856543260ce09b460a7bc852747", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-02-27T09:26:54+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-02-27T09:26:54+00:00" + }, + { + "name": "symfony/process", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", + "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", + "shasum": "" + }, + "require": { + "php": "^7.2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2020-03-27T16:56:45+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "144c5e51266b281231e947b51223ba14acf1a749" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749", + "reference": "144c5e51266b281231e947b51223ba14acf1a749", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "psr/container": "^1.0" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-11-18T17:27:11+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v5.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/a1d86d30d4522423afc998f32404efa34fcf5a73", + "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "symfony/service-contracts": "^1.0|^2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2020-03-27T16:56:45+00:00" }, { "name": "theseer/tokenizer", @@ -1361,7 +3019,7 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2017-04-07 12:08:54" + "time": "2017-04-07T12:08:54+00:00" }, { "name": "webmozart/assert", @@ -1411,7 +3069,7 @@ "check", "validate" ], - "time": "2018-01-29 19:49:41" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php new file mode 100644 index 0000000..c08ace2 --- /dev/null +++ b/src/Command/BuyItemCommand.php @@ -0,0 +1,20 @@ +input = $input; + } + + public function execute(): void + { + $this->input; + } +} diff --git a/src/Command/Command.php b/src/Command/Command.php new file mode 100644 index 0000000..84fcd54 --- /dev/null +++ b/src/Command/Command.php @@ -0,0 +1,8 @@ +value; + } +} diff --git a/src/Model/Dollar.php b/src/Model/Dollar.php new file mode 100644 index 0000000..4f71b96 --- /dev/null +++ b/src/Model/Dollar.php @@ -0,0 +1,10 @@ +service() . "\n"; + echo $vm->execute() . "\n"; break; } } diff --git a/tests/Factory/CommandFactoryTest.php b/tests/Factory/CommandFactoryTest.php new file mode 100644 index 0000000..67232c6 --- /dev/null +++ b/tests/Factory/CommandFactoryTest.php @@ -0,0 +1,20 @@ +create('Q, Q, Q, Q, GET-B'); + + self::assertInstanceOf(BuyItemCommand::class, $command); + } +} diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 5419835..92c2cb8 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -2,25 +2,23 @@ declare(strict_types=1); -namespace VendingMachine; +namespace Tests\VendingMachine; +use VendingMachine\VendingMachine; use PHPUnit\Framework\TestCase; final class VendingMachineTest extends TestCase { - /** - * @var VendingMachine - */ + /** @var VendingMachine */ private $vendingMachine; public function setUp(): void { - $vm = new VendingMachine(); - $this->vendingMachine = $vm; + $this->vendingMachine = new VendingMachine(); } public function testServiceReturnsNoService(): void { - $this->assertEquals('service', $this->vendingMachine->service()); + $this->assertEquals('test', $this->vendingMachine->execute('test')); } } From d6da82e3de2830a351ac8f113fd9fe6478be84de Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sun, 5 Apr 2020 11:49:43 +0200 Subject: [PATCH 07/87] feat: create item classes --- src/Item/ItemA.php | 15 +++++++++++++++ src/Item/ItemB.php | 18 ++++++++++++++++++ src/Item/ItemC.php | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/Item/ItemA.php create mode 100644 src/Item/ItemB.php create mode 100644 src/Item/ItemC.php diff --git a/src/Item/ItemA.php b/src/Item/ItemA.php new file mode 100644 index 0000000..5381e5d --- /dev/null +++ b/src/Item/ItemA.php @@ -0,0 +1,15 @@ +value; + } +} diff --git a/src/Item/ItemB.php b/src/Item/ItemB.php new file mode 100644 index 0000000..c9ef47e --- /dev/null +++ b/src/Item/ItemB.php @@ -0,0 +1,18 @@ +value; + } +} diff --git a/src/Item/ItemC.php b/src/Item/ItemC.php new file mode 100644 index 0000000..21c5cf0 --- /dev/null +++ b/src/Item/ItemC.php @@ -0,0 +1,18 @@ +value; + } +} From bfa026279c8a9e9362d9ef36926847159d982616 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sun, 5 Apr 2020 11:49:56 +0200 Subject: [PATCH 08/87] feat: create ConsoleRequest --- src/Request/ConsoleRequest.php | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Request/ConsoleRequest.php diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php new file mode 100644 index 0000000..dec5700 --- /dev/null +++ b/src/Request/ConsoleRequest.php @@ -0,0 +1,40 @@ +action = $action; + } + + public function addMoney(Money $money) + { + $this->money[] = $money; + } + + public function assertAction(string $action) + { + + } + + public function action(): string + { + return $this->action; + } +} From 9d75d5f15ab1d6379d4047e8247c9d942c575750 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sun, 5 Apr 2020 11:50:45 +0200 Subject: [PATCH 09/87] feat: add InputParser interface, add ConsoleInputParser --- src/Util/ConsoleInputParser.php | 19 +++++++++++++++++++ src/Util/InputParser.php | 10 ++++++++++ tests/Request/ConsoleRequestTest.php | 22 ++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/Util/ConsoleInputParser.php create mode 100644 src/Util/InputParser.php create mode 100644 tests/Request/ConsoleRequestTest.php diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php new file mode 100644 index 0000000..6ef2e14 --- /dev/null +++ b/src/Util/ConsoleInputParser.php @@ -0,0 +1,19 @@ +action()); + } +} From b6e708f9343368814b02b8a4f7899f3d2ebdb714 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sun, 5 Apr 2020 21:25:00 +0200 Subject: [PATCH 10/87] feat: create object to contain parsed request --- src/Request/ConsoleRequest.php | 13 ++++++++++--- tests/Request/ConsoleRequestTest.php | 7 +++++++ tests/Util/InputParserTest.php | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tests/Util/InputParserTest.php diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index dec5700..7cb7af8 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -1,9 +1,9 @@ assertAction($action); + $this->action = $action; } @@ -28,9 +30,14 @@ public function addMoney(Money $money) $this->money[] = $money; } - public function assertAction(string $action) + /** + * @param string $action + */ + public function assertAction(string $action): void { - + if (!preg_match('/GET-[A-C]/', $action)) { + throw new \InvalidArgumentException('Invalid action name!'); + } } public function action(): string diff --git a/tests/Request/ConsoleRequestTest.php b/tests/Request/ConsoleRequestTest.php index e5f18ec..4f80f4b 100644 --- a/tests/Request/ConsoleRequestTest.php +++ b/tests/Request/ConsoleRequestTest.php @@ -19,4 +19,11 @@ public function testShouldReturnAction(): void { self::assertEquals('GET-B', (new ConsoleRequest('GET-B'))->action()); } + + public function testShouldThrowInvalidArgumentExceptionWhenActionNameIsInvalid(): void + { + self::expectException(\InvalidArgumentException::class); + + new ConsoleRequest('test'); + } } diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php new file mode 100644 index 0000000..1555a37 --- /dev/null +++ b/tests/Util/InputParserTest.php @@ -0,0 +1,19 @@ +parse('Q, Q, Q, Q, GET-B'); + + // ? class BuyRequest ? + } +} From e0abfed0c732ae6971ad4da35ed6d6de60b97a87 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 6 Apr 2020 21:33:27 +0200 Subject: [PATCH 11/87] feat: add Item interface --- src/Item/Item.php | 10 ++++++++++ src/Item/ItemA.php | 9 ++++++++- src/Item/ItemB.php | 12 ++++++++---- src/Item/ItemC.php | 12 ++++++++---- 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/Item/Item.php diff --git a/src/Item/Item.php b/src/Item/Item.php new file mode 100644 index 0000000..ddcc91a --- /dev/null +++ b/src/Item/Item.php @@ -0,0 +1,10 @@ +value; } + + public function selector(): string + { + return self::SELECTOR; + } } diff --git a/src/Item/ItemB.php b/src/Item/ItemB.php index c9ef47e..ef3015f 100644 --- a/src/Item/ItemB.php +++ b/src/Item/ItemB.php @@ -4,15 +4,19 @@ namespace VendingMachine\Item; -class ItemB +class ItemB implements Item { + private const SELECTOR = 'B'; + private int $value = 100; - /** - * @return int - */ public function getValue(): int { return $this->value; } + + public function selector(): string + { + return self::SELECTOR; + } } diff --git a/src/Item/ItemC.php b/src/Item/ItemC.php index 21c5cf0..228cb35 100644 --- a/src/Item/ItemC.php +++ b/src/Item/ItemC.php @@ -4,15 +4,19 @@ namespace VendingMachine\Item; -class ItemC +class ItemC implements Item { + private const SELECTOR = 'C'; + private int $value = 150; - /** - * @return int - */ public function getValue(): int { return $this->value; } + + public function selector(): string + { + return self::SELECTOR; + } } From b5c1587090ad262b399e0c1db0812dbb00bd88e5 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 6 Apr 2020 21:36:26 +0200 Subject: [PATCH 12/87] feat: return Money from Request --- src/Request/ConsoleRequest.php | 10 +++++++++- tests/Request/ConsoleRequestTest.php | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index 7cb7af8..32cb68e 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -25,7 +25,10 @@ public function __construct(string $action) $this->action = $action; } - public function addMoney(Money $money) + /** + * @param Money $money + */ + public function addMoney(Money $money): void { $this->money[] = $money; } @@ -44,4 +47,9 @@ public function action(): string { return $this->action; } + + public function money(): array + { + return $this->money; + } } diff --git a/tests/Request/ConsoleRequestTest.php b/tests/Request/ConsoleRequestTest.php index 4f80f4b..765a8fb 100644 --- a/tests/Request/ConsoleRequestTest.php +++ b/tests/Request/ConsoleRequestTest.php @@ -5,7 +5,7 @@ namespace Tests\Request; use PHPUnit\Framework\TestCase; -use SebastianBergmann\Environment\Console; +use VendingMachine\Model\Dime; use VendingMachine\Request\ConsoleRequest; class ConsoleRequestTest extends TestCase @@ -26,4 +26,12 @@ public function testShouldThrowInvalidArgumentExceptionWhenActionNameIsInvalid() new ConsoleRequest('test'); } + + public function testShouldAddMoneyToRequest(): void + { + $consoleRequest = new ConsoleRequest('GET-B'); + $consoleRequest->addMoney(new Dime()); + + self::assertEquals([new Dime()], $consoleRequest->money()); + } } From a3ffa292163311700f38b7552881400b863bad86 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 6 Apr 2020 21:43:10 +0200 Subject: [PATCH 13/87] feat: ItemRepository interface --- src/Repository/ItemRepository.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/Repository/ItemRepository.php diff --git a/src/Repository/ItemRepository.php b/src/Repository/ItemRepository.php new file mode 100644 index 0000000..0df216e --- /dev/null +++ b/src/Repository/ItemRepository.php @@ -0,0 +1,10 @@ + Date: Wed, 8 Apr 2020 21:28:39 +0200 Subject: [PATCH 14/87] feat: move methods to abstract class for Item --- src/Item/Item.php | 23 ++++++++++++++++++++--- src/Item/ItemA.php | 16 +++------------- src/Item/ItemB.php | 16 +++------------- src/Item/ItemC.php | 18 ++++-------------- 4 files changed, 30 insertions(+), 43 deletions(-) diff --git a/src/Item/Item.php b/src/Item/Item.php index ddcc91a..dc54efe 100644 --- a/src/Item/Item.php +++ b/src/Item/Item.php @@ -1,10 +1,27 @@ value; + } + + public function selector(): string + { + return $this->selector; + } + + public function equalsBySelector(string $selector): bool + { + return $this->selector === $selector; + } } diff --git a/src/Item/ItemA.php b/src/Item/ItemA.php index 3a2f4f7..650a553 100644 --- a/src/Item/ItemA.php +++ b/src/Item/ItemA.php @@ -4,19 +4,9 @@ namespace VendingMachine\Item; -class ItemA implements Item +class ItemA extends Item { - private const SELECTOR = 'B'; + protected string $selector = 'A'; - private int $value = 65; - - public function value(): int - { - return $this->value; - } - - public function selector(): string - { - return self::SELECTOR; - } + protected int $value = 65; } diff --git a/src/Item/ItemB.php b/src/Item/ItemB.php index ef3015f..01eb803 100644 --- a/src/Item/ItemB.php +++ b/src/Item/ItemB.php @@ -4,19 +4,9 @@ namespace VendingMachine\Item; -class ItemB implements Item +class ItemB extends Item { - private const SELECTOR = 'B'; + protected string $selector = 'B'; - private int $value = 100; - - public function getValue(): int - { - return $this->value; - } - - public function selector(): string - { - return self::SELECTOR; - } + protected int $value = 100; } diff --git a/src/Item/ItemC.php b/src/Item/ItemC.php index 228cb35..b7673e2 100644 --- a/src/Item/ItemC.php +++ b/src/Item/ItemC.php @@ -1,22 +1,12 @@ value; - } + protected string $selector = 'C'; - public function selector(): string - { - return self::SELECTOR; - } + protected int $value = 150; } From d5b181c7ff261f05df8d8f90a7d64d0002ffef99 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Wed, 8 Apr 2020 21:28:59 +0200 Subject: [PATCH 15/87] test: add simple Item unit tests --- tests/Item/ItemTest.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/Item/ItemTest.php diff --git a/tests/Item/ItemTest.php b/tests/Item/ItemTest.php new file mode 100644 index 0000000..6fc202f --- /dev/null +++ b/tests/Item/ItemTest.php @@ -0,0 +1,32 @@ +value()); + } + + public function testShouldReturnSelector(): void + { + $itemA = new ItemA(); + + self::assertEquals('A', $itemA->selector()); + } + + public function testShouldReturnTrueWhenItemEquals(): void + { + $itemA = new ItemA(); + + self::assertTrue($itemA->equalsBySelector('A')); + } +} From 8748d8dd79fd4cfc9371a5f6a8f484a4692d48dd Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Wed, 8 Apr 2020 21:29:30 +0200 Subject: [PATCH 16/87] feat: implementation of in memory repository --- src/Repository/InMemoryItemRepository.php | 32 +++++++++++++++++++++++ src/Repository/ItemRepository.php | 7 ++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/Repository/InMemoryItemRepository.php diff --git a/src/Repository/InMemoryItemRepository.php b/src/Repository/InMemoryItemRepository.php new file mode 100644 index 0000000..f20f63f --- /dev/null +++ b/src/Repository/InMemoryItemRepository.php @@ -0,0 +1,32 @@ +items[] = $item; + } + + public function getItemBySelector($selector): ?Item + { + $filtered = array_filter($this->items, static function(Item $item) use ($selector) { + return $item->equalsBySelector($selector); + }); + + return count($filtered) ? reset($filtered) : null; + } + + public function getAll(): array + { + return $this->items; + } +} diff --git a/src/Repository/ItemRepository.php b/src/Repository/ItemRepository.php index 0df216e..bb357ff 100644 --- a/src/Repository/ItemRepository.php +++ b/src/Repository/ItemRepository.php @@ -6,5 +6,10 @@ interface ItemRepository { - public function getItemBySelector($selector): Item; + public function add(Item $item): void; + + public function getItemBySelector($selector): ?Item; + + /** @return array|Item[] */ + public function getAll(): array; } From edb9006c1f31099c7d7d645c54097263772bcc96 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Wed, 8 Apr 2020 21:29:45 +0200 Subject: [PATCH 17/87] feat: Dime extends Money --- src/Model/Dime.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Dime.php b/src/Model/Dime.php index 88380e2..378e514 100644 --- a/src/Model/Dime.php +++ b/src/Model/Dime.php @@ -4,12 +4,12 @@ namespace VendingMachine\Model; -class Dime implements Coin +class Dime extends Money implements Coin { /** @var int */ private int $value = 25; - public function value(): Value + public function value(): int { return $this->value; } From d8c1ec274c9639b6cc9e302ec3cc189d1d4c6c1c Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Wed, 8 Apr 2020 21:30:13 +0200 Subject: [PATCH 18/87] test: in memory repository --- .../Repository/InMemoryItemRepositoryTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/Repository/InMemoryItemRepositoryTest.php diff --git a/tests/Repository/InMemoryItemRepositoryTest.php b/tests/Repository/InMemoryItemRepositoryTest.php new file mode 100644 index 0000000..bfe1804 --- /dev/null +++ b/tests/Repository/InMemoryItemRepositoryTest.php @@ -0,0 +1,34 @@ +add(new ItemA()); + + self::assertEquals([new ItemA()], $repository->getAll()); + } + + public function testShouldReturnItemBySelector(): void + { + $repository = new InMemoryItemRepository(); + $repository->add(new ItemA()); + $repository->add(new ItemB()); + $repository->add(new ItemC()); + + $result = $repository->getItemBySelector((new ItemB())->selector()); + + self::assertEquals(new ItemB(), $result); + } +} From ecc3a0595d9826bed1a2f0cf5ce10c0b4a1c5422 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Wed, 8 Apr 2020 21:37:12 +0200 Subject: [PATCH 19/87] feat: add values to Money classes --- src/Model/Coin.php | 2 +- src/Model/Dime.php | 10 ++-------- src/Model/Dollar.php | 3 ++- src/Model/Item.php | 12 ------------ src/Model/Money.php | 5 ++++- src/Model/Nickel.php | 6 +++--- src/Model/{Value.php => PaperMoney.php} | 4 ++-- src/Model/Quarter.php | 10 +++------- 8 files changed, 17 insertions(+), 35 deletions(-) delete mode 100644 src/Model/Item.php rename src/Model/{Value.php => PaperMoney.php} (50%) diff --git a/src/Model/Coin.php b/src/Model/Coin.php index 10aa79a..4cb25e6 100644 --- a/src/Model/Coin.php +++ b/src/Model/Coin.php @@ -6,5 +6,5 @@ interface Coin { - public function value(): int; + } diff --git a/src/Model/Dime.php b/src/Model/Dime.php index 378e514..0b97732 100644 --- a/src/Model/Dime.php +++ b/src/Model/Dime.php @@ -4,13 +4,7 @@ namespace VendingMachine\Model; -class Dime extends Money implements Coin +final class Dime extends Money implements Coin { - /** @var int */ - private int $value = 25; - - public function value(): int - { - return $this->value; - } + protected int $value = 10; } diff --git a/src/Model/Dollar.php b/src/Model/Dollar.php index 4f71b96..a2398e6 100644 --- a/src/Model/Dollar.php +++ b/src/Model/Dollar.php @@ -4,7 +4,8 @@ namespace VendingMachine\Model; -class Dollar +final class Dollar extends Money implements PaperMoney { + protected int $value = 100; } diff --git a/src/Model/Item.php b/src/Model/Item.php deleted file mode 100644 index dc562a1..0000000 --- a/src/Model/Item.php +++ /dev/null @@ -1,12 +0,0 @@ -value; + } } diff --git a/src/Model/Nickel.php b/src/Model/Nickel.php index 77d079c..e06079c 100644 --- a/src/Model/Nickel.php +++ b/src/Model/Nickel.php @@ -1,10 +1,10 @@ Date: Sun, 12 Apr 2020 20:36:33 +0200 Subject: [PATCH 20/87] feat: add enum with available money --- src/Model/AvailableMoney.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/Model/AvailableMoney.php diff --git a/src/Model/AvailableMoney.php b/src/Model/AvailableMoney.php new file mode 100644 index 0000000..82555b2 --- /dev/null +++ b/src/Model/AvailableMoney.php @@ -0,0 +1,19 @@ + Date: Sun, 12 Apr 2020 20:36:57 +0200 Subject: [PATCH 21/87] feat: add ShortCode to money --- src/Model/Dime.php | 2 ++ src/Model/Dollar.php | 3 ++- src/Model/Money.php | 5 ++++ src/Model/Nickel.php | 2 ++ src/Model/Quarter.php | 2 ++ tests/Util/InputParserTest.php | 42 ++++++++++++++++++++++++++++++---- 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/Model/Dime.php b/src/Model/Dime.php index 0b97732..8c104c4 100644 --- a/src/Model/Dime.php +++ b/src/Model/Dime.php @@ -6,5 +6,7 @@ final class Dime extends Money implements Coin { + protected string $shortCode = 'D'; + protected int $value = 10; } diff --git a/src/Model/Dollar.php b/src/Model/Dollar.php index a2398e6..b795bd5 100644 --- a/src/Model/Dollar.php +++ b/src/Model/Dollar.php @@ -6,6 +6,7 @@ final class Dollar extends Money implements PaperMoney { - protected int $value = 100; + protected string $shortCode = 'Dollar'; + protected int $value = 100; } diff --git a/src/Model/Money.php b/src/Model/Money.php index 2b54c4e..03b95b2 100644 --- a/src/Model/Money.php +++ b/src/Model/Money.php @@ -6,6 +6,11 @@ abstract class Money { + public function shortCode(): string + { + return $this->shortCode; + } + public function value(): int { return $this->value; diff --git a/src/Model/Nickel.php b/src/Model/Nickel.php index e06079c..6778b9e 100644 --- a/src/Model/Nickel.php +++ b/src/Model/Nickel.php @@ -6,5 +6,7 @@ final class Nickel extends Money implements Coin { + protected string $shortCode = 'DollarDollar'; + protected int $value = 5; } diff --git a/src/Model/Quarter.php b/src/Model/Quarter.php index d4c28d4..520085d 100644 --- a/src/Model/Quarter.php +++ b/src/Model/Quarter.php @@ -6,5 +6,7 @@ class Quarter extends Money implements Coin { + protected string $shortCode = 'Q'; + protected int $value = 25; } diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index 1555a37..fd93379 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -5,15 +5,49 @@ namespace Tests\Util; use PHPUnit\Framework\TestCase; +use VendingMachine\Model\Quarter; +use VendingMachine\Request\ConsoleRequest; use VendingMachine\Util\ConsoleInputParser; class InputParserTest extends TestCase { - public function testShouldParseBuyItemInput(): void + /** + * @var ConsoleInputParser + */ + private ConsoleInputParser $parser; + + protected function setUp() + { + $this->parser = new ConsoleInputParser(); + } + + public function testShouldParseBuyItemInputAndReturnConsoleRequest(): void + { + $request = $this->parser->parse('Q, Q, Q, Q, GET-B'); + + self::assertInstanceOf(ConsoleRequest::class, $request); + } + + public function testShouldParseInputAndReturnConsoleRequestWithActionGet(): void + { + $request = $this->parser->parse('Q, Q, Q, Q, GET-B'); + + self::assertEquals('GET-B', $request->action()); + } + + public function testShouldParseInputAndReturnConsoleRequestWith4QuarterMoney(): void { - $parser = new ConsoleInputParser(); - $request = $parser->parse('Q, Q, Q, Q, GET-B'); + $request = $this->parser->parse('Q, Q, Q, Q, GET-B'); + - // ? class BuyRequest ? + self::assertEquals( + [ + new Quarter(), + new Quarter(), + new Quarter(), + new Quarter(), + ], + $request->money() + ); } } From 9088be3c3f8444b4483fb5be38238032f52da1f5 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Sun, 12 Apr 2020 20:37:21 +0200 Subject: [PATCH 22/87] feat: console parser with tests --- src/Request/ConsoleRequest.php | 8 +++++ src/Util/ConsoleInputParser.php | 60 +++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index 32cb68e..958083a 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -33,6 +33,14 @@ public function addMoney(Money $money): void $this->money[] = $money; } + /** + * @param Money[] + */ + public function setMoney(array $moneys): void + { + $this->money = $moneys; + } + /** * @param string $action */ diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php index 6ef2e14..02bde8b 100644 --- a/src/Util/ConsoleInputParser.php +++ b/src/Util/ConsoleInputParser.php @@ -4,16 +4,72 @@ namespace VendingMachine\Util; +use VendingMachine\Model\AvailableMoney; +use VendingMachine\Model\Money; +use VendingMachine\Request\ConsoleRequest; + class ConsoleInputParser implements InputParser { - public function parse(string $input): array + public function parse(string $input): ConsoleRequest + { + $parameters = $this->splitParameters($input); + + $action = $this->filterAction($parameters); + $consoleRequest = new ConsoleRequest($action); + + $money = $this->filterMoney($parameters); + + $consoleRequest->setMoney($money); + + return $consoleRequest; + } + + private function splitParameters(string $input): array { $request = explode(',', $input); return array_map(static function($element) { return trim($element); }, $request); + } - // parse to request + private function filterAction(array $parameters): string + { + $action = null; + /** @var string $parameter */ + foreach ($parameters as $parameter) { + // filter action - set to ConsoleRequest + if (preg_match('/GET-[A-C]/', $parameter)) { + $action = $parameter; + } + } + + if ($action === null) { + throw new \LogicException('No action found!'); + } + return $action; } + + public function filterMoney(array $parameters): array + { + $money = []; + /** @var string $parameter */ + foreach ($parameters as $parameter) { + $results = array_filter(AvailableMoney::getMoney(), static function(Money $money) use ($parameter) { + return $money->shortCode() === $parameter; + }); + + if (count($results) === 1) { + $money[] = reset($results); + } + + } + + if (empty($money)) { + throw new \InvalidArgumentException('Any money throw into vending machine!'); + } + + return $money; + } + } From e11f34ac3bccee12717e00553377cf71152f75f9 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:09:53 +0200 Subject: [PATCH 23/87] feat: BuyItemCommand implementation on interfaces, simple test --- tests/Command/BuyItemCommandTest.php | 31 ++++++++++++++++++++++++++++ tests/Factory/CommandFactoryTest.php | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 tests/Command/BuyItemCommandTest.php diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php new file mode 100644 index 0000000..c09ee29 --- /dev/null +++ b/tests/Command/BuyItemCommandTest.php @@ -0,0 +1,31 @@ +add(new ItemB()); + + $buyItemCommand = new BuyItemCommand($itemRepository); + + $result = $buyItemCommand->execute( + new BuyItemRequest(new ItemB(), new MoneyCollection([new Dollar()])) + ); + + self::assertTrue($result); + } +} diff --git a/tests/Factory/CommandFactoryTest.php b/tests/Factory/CommandFactoryTest.php index 67232c6..dc97786 100644 --- a/tests/Factory/CommandFactoryTest.php +++ b/tests/Factory/CommandFactoryTest.php @@ -12,6 +12,8 @@ class CommandFactoryTest extends TestCase { public function testShouldReturnByItemCommand(): void { + $this->markTestSkipped(); + $commandFactory = new CommandFactory(); $command = $commandFactory->create('Q, Q, Q, Q, GET-B'); From 2ac0b066fdaca02a48c6269e08c9b1a3fe8b3620 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:10:28 +0200 Subject: [PATCH 24/87] feat: method for simple model creation --- src/Model/Money.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Model/Money.php b/src/Model/Money.php index 03b95b2..daaa332 100644 --- a/src/Model/Money.php +++ b/src/Model/Money.php @@ -15,4 +15,9 @@ public function value(): int { return $this->value; } + + public function create(): Money + { + return new static(); + } } From 18ab0866f8e7f98ac998327724f04ea3160976b1 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:10:50 +0200 Subject: [PATCH 25/87] fix: short code for Nickel --- src/Model/Nickel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Nickel.php b/src/Model/Nickel.php index 6778b9e..1b16395 100644 --- a/src/Model/Nickel.php +++ b/src/Model/Nickel.php @@ -6,7 +6,7 @@ final class Nickel extends Money implements Coin { - protected string $shortCode = 'DollarDollar'; + protected string $shortCode = 'N'; protected int $value = 5; } From 45d7d4e5b54d39d3198a45fc69203facaea72f2b Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:11:14 +0200 Subject: [PATCH 26/87] feat: Collection to managing money --- src/Model/MoneyCollection.php | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Model/MoneyCollection.php diff --git a/src/Model/MoneyCollection.php b/src/Model/MoneyCollection.php new file mode 100644 index 0000000..12b7dc5 --- /dev/null +++ b/src/Model/MoneyCollection.php @@ -0,0 +1,45 @@ +addMoney($money); + } + } + + public function addMoney(Money $money): void + { + $this->money[] = $money; + } + + /** + * @return array|Money[] + */ + public function money() + { + return $this->money; + } + + /** + * @inheritDoc + */ + public function count() + { + $sum = 0; + + foreach ($this->money as $money) { + $sum += $money->value(); + } + + return $sum; + } +} From 334dce1d6b31bc074a3c9b9be4d147f5de6d33fd Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:21:18 +0200 Subject: [PATCH 27/87] test: MoneyCollectionTest --- tests/Model/MoneyCollectionTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/Model/MoneyCollectionTest.php diff --git a/tests/Model/MoneyCollectionTest.php b/tests/Model/MoneyCollectionTest.php new file mode 100644 index 0000000..5603add --- /dev/null +++ b/tests/Model/MoneyCollectionTest.php @@ -0,0 +1,24 @@ +count()); + } +} From 3c058289d39e3600fbe3813dad5837b03751eae5 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:21:48 +0200 Subject: [PATCH 28/87] feat: implement Interface for Request --- src/Request/ConsoleRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index 958083a..ec1fd30 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -6,7 +6,7 @@ use VendingMachine\Model\Money; -class ConsoleRequest +class ConsoleRequest implements Request { /** * @var array Money[] @@ -16,7 +16,7 @@ class ConsoleRequest /** * @var string */ - private string $action; + protected string $action; public function __construct(string $action) { From da033e2c64ba60feedf2101af36075482e5406f6 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 14:25:15 +0200 Subject: [PATCH 29/87] test: test for calculating rest with exact and not --- tests/Coordinator/PaymentCoordinatorTest.php | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/Coordinator/PaymentCoordinatorTest.php diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php new file mode 100644 index 0000000..824b9bb --- /dev/null +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -0,0 +1,69 @@ +pay(100, 100); + + self::assertEquals(0, $rest->count()); + self::assertEquals([], $rest->money()); + } + + public function testShouldReturnRestInTwoQuarter(): void + { + $paymentCoordinator = new PaymentCoordinator(); + $rest = $paymentCoordinator->pay(100, 50); + + + self::assertEquals(50, $rest->count()); + self::assertEquals( + [ + new Quarter(), + new Quarter() + ], + $rest->money() + ); + } + + public function testShouldReturnRestInTwoDime(): void + { + $paymentCoordinator = new PaymentCoordinator(); + $rest = $paymentCoordinator->pay(70, 50); + + self::assertEquals(20, $rest->count()); + self::assertEquals( + [ + new Dime(), + new Dime() + ], + $rest->money() + ); + } + + public function testShouldReturnRestInQuarterAndDime(): void + { + $paymentCoordinator = new PaymentCoordinator(); + $rest = $paymentCoordinator->pay(100, 65); + + self::assertEquals(35, $rest->count()); + self::assertEquals( + [ + new Quarter(), + new Dime() + ], + $rest->money() + ); + } + +} From 28f48184aed11f80f5b64dcf9b7b97a6df7bb68f Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 15:23:45 +0200 Subject: [PATCH 30/87] test: BuyItemCommand valid return type --- tests/Command/BuyItemCommandTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php index c09ee29..26c3f70 100644 --- a/tests/Command/BuyItemCommandTest.php +++ b/tests/Command/BuyItemCommandTest.php @@ -6,12 +6,14 @@ use PHPUnit\Framework\TestCase; use VendingMachine\Command\BuyItemCommand; +use VendingMachine\Coordinator\PaymentCoordinator; use VendingMachine\Item\ItemB; use VendingMachine\Model\Dollar; use VendingMachine\Model\MoneyCollection; use VendingMachine\Repository\InMemoryItemRepository; use VendingMachine\Request\BuyItemRequest; use VendingMachine\Request\ConsoleRequest; +use VendingMachine\Response\ConsoleResponse; class BuyItemCommandTest extends TestCase { @@ -20,12 +22,12 @@ public function testShouldReturnBoughtBItem(): void $itemRepository = new InMemoryItemRepository(); $itemRepository->add(new ItemB()); - $buyItemCommand = new BuyItemCommand($itemRepository); + $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); $result = $buyItemCommand->execute( new BuyItemRequest(new ItemB(), new MoneyCollection([new Dollar()])) ); - self::assertTrue($result); + self::assertInstanceOf(ConsoleResponse::class, $result); } } From ac6f452c3e631ec3f4359ba9adf8bf68a61e6d33 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 15:24:38 +0200 Subject: [PATCH 31/87] ref: remove unused use statements --- src/Command/BuyItemCommand.php | 51 +++++++++++++++++++++++++++++----- src/Command/Command.php | 6 +++- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index c08ace2..0ffa00a 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -4,17 +4,54 @@ namespace VendingMachine\Command; -class BuyItemCommand implements Command +use VendingMachine\Coordinator\PaymentCoordinator; +use VendingMachine\Repository\ItemRepository; +use VendingMachine\Request\BuyItemRequest; +use VendingMachine\Response\ConsoleResponse; + +class BuyItemCommand { - private $input; + /** + * @var ItemRepository + */ + private ItemRepository $itemRepository; - public function __construct($input) - { - $this->input = $input; + /** + * @var PaymentCoordinator + */ + private PaymentCoordinator $paymentCoordinator; + + /** + * @var ConsoleResponse + */ + private ConsoleResponse $response; + + public function __construct( + ItemRepository $itemRepository, + PaymentCoordinator $paymentCoordinator, + ConsoleResponse $response + ) { + $this->itemRepository = $itemRepository; + $this->paymentCoordinator = $paymentCoordinator; + $this->response = $response; } - public function execute(): void + public function execute(BuyItemRequest $request): ConsoleResponse { - $this->input; + $item = $request->item(); + $moneys = $request->moneyCollection(); + + $availableItem = $this->itemRepository->getItemBySelector($item->selector()); + + if ($availableItem === null) { + throw new \InvalidArgumentException(sprintf('Item %s is not available', $item->selector())); + } + + if ($item->enougthToBuy($moneys->count())) { + $rest = $this->paymentCoordinator->pay($moneys->count(), $availableItem->value()); + return $this->response->setRest($rest); + } + + throw new \InvalidArgumentException('Set enough money to buy Item!'); } } diff --git a/src/Command/Command.php b/src/Command/Command.php index 84fcd54..505a19d 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -1,8 +1,12 @@ Date: Mon, 13 Apr 2020 20:15:58 +0200 Subject: [PATCH 32/87] feat: PaymentCoordinator - calculate rest of payment --- src/Coordinator/PaymentCoordinator.php | 64 ++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/Coordinator/PaymentCoordinator.php diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php new file mode 100644 index 0000000..152953d --- /dev/null +++ b/src/Coordinator/PaymentCoordinator.php @@ -0,0 +1,64 @@ += $cost) { + $rest = $input - $cost; + $coinRest = $this->calculateRest($rest, $this->getCoins()); + return new MoneyCollection($coinRest); + } + + throw new \InvalidArgumentException('No enough money to pay for it!'); + + } + + private function calculateRest(int $rest, array $coins): array + { + $coinRest = []; + /** @var Money $coin */ + foreach ($coins as $coin) { + if ($coin->value() <= $rest) { + + $multiplication = $rest / $coin->value(); + $integerMultiplication = (int) $multiplication; + + for ($i = 0; $i < $integerMultiplication; $i++) { + $coinRest[] = $coin->create(); + } + + $rest -= $coin->value() * $integerMultiplication; + + if ($rest === 0) { + break; + } + } + } + + return $coinRest; + } + + private function getCoins(): array + { + $coins = array_filter(AvailableMoney::getMoney(), static function(Money $money) { + return $money instanceof Coin; + }); + // sort DESC + usort($coins, static function(Money $a, Money $b) { + return $a->value() < $b->value(); + }); + + return $coins; + } + +} From 51a1b84d230968dd59604612fe30f3080d70d7db Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 20:17:18 +0200 Subject: [PATCH 33/87] feat: VendingMachine - execute BuyItemCommand service --- src/VendingMachine.php | 43 ++++++++++++++++++++++++++++++++++++++++-- src/prompt.php | 14 ++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/VendingMachine.php b/src/VendingMachine.php index 1733b30..5298de6 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -4,10 +4,49 @@ namespace VendingMachine; -final class VendingMachine { +use VendingMachine\Command\BuyItemCommand; +use VendingMachine\Coordinator\PaymentCoordinator; +use VendingMachine\Item\ItemB; +use VendingMachine\Repository\ItemRepository; +use VendingMachine\Request\BuyItemRequest; +use VendingMachine\Request\ConsoleRequest; +use VendingMachine\Response\ConsoleResponse; +use VendingMachine\Util\InputParser; + +final class VendingMachine +{ + + /** + * @var ItemRepository + */ + private ItemRepository $itemRepository; + /** + * @var InputParser + */ + private InputParser $inputParser; + + public function __construct(ItemRepository $itemRepository, InputParser $inputParser) + { + $this->itemRepository = $itemRepository; + $this->inputParser = $inputParser; + } public function execute(string $input): string { - return $input; + $request = $this->parseInput($input); + + $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); + + $response = $buyCommand->execute( + new BuyItemRequest(new ItemB(), $request->moneyCollection()) + ); + + return $response->getOutput(); + } + + private function parseInput(string $input): ConsoleRequest + { + /** @var ConsoleRequest $request */ + return $this->inputParser->parse($input); } } diff --git a/src/prompt.php b/src/prompt.php index c62002b..4152068 100644 --- a/src/prompt.php +++ b/src/prompt.php @@ -4,9 +4,17 @@ require_once '../vendor/autoload.php'; +use VendingMachine\Item\ItemB; +use VendingMachine\Repository\InMemoryItemRepository; +use VendingMachine\Util\ConsoleInputParser; use VendingMachine\VendingMachine; -$vm = new VendingMachine(); + +$itemRepository = new InMemoryItemRepository(); +$itemRepository->add(new ItemB()); + + +$vm = new VendingMachine($itemRepository, new ConsoleInputParser()); $input = ''; while ($input !== 'exit') { @@ -15,7 +23,9 @@ switch ($input) { case 'service': - echo $vm->execute() . "\n"; + echo $vm->execute($input) . "\n"; break; + default: + echo $vm->execute($input) . "\n"; } } From 279b7f18ba4b02aa15f046033c5d9ee26d80ed27 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 20:18:20 +0200 Subject: [PATCH 34/87] feat: InputParser add MoneyCollection typing --- src/Util/ConsoleInputParser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php index 02bde8b..c0f6c0e 100644 --- a/src/Util/ConsoleInputParser.php +++ b/src/Util/ConsoleInputParser.php @@ -6,6 +6,7 @@ use VendingMachine\Model\AvailableMoney; use VendingMachine\Model\Money; +use VendingMachine\Model\MoneyCollection; use VendingMachine\Request\ConsoleRequest; class ConsoleInputParser implements InputParser @@ -19,7 +20,7 @@ public function parse(string $input): ConsoleRequest $money = $this->filterMoney($parameters); - $consoleRequest->setMoney($money); + $consoleRequest->setMoney(new MoneyCollection($money)); return $consoleRequest; } From a4123515fa36c27444e122fff8f330cb9b0ed611 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 20:18:45 +0200 Subject: [PATCH 35/87] feat: simple class for Response --- src/Response/ConsoleResponse.php | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Response/ConsoleResponse.php diff --git a/src/Response/ConsoleResponse.php b/src/Response/ConsoleResponse.php new file mode 100644 index 0000000..5fb6ba4 --- /dev/null +++ b/src/Response/ConsoleResponse.php @@ -0,0 +1,38 @@ +rest = $rest; + return $this; + } + + /** + * @return MoneyCollection + */ + public function rest(): MoneyCollection + { + return $this->rest; + } + + public function getOutput(): string + { + return "resztaaa! \n"; + } +} From 2b348d3d92e1edd2c08abe0292073ee3ae118017 Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 20:19:24 +0200 Subject: [PATCH 36/87] feat: Request for buy services --- src/Request/BuyItemRequest.php | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Request/BuyItemRequest.php diff --git a/src/Request/BuyItemRequest.php b/src/Request/BuyItemRequest.php new file mode 100644 index 0000000..a916f82 --- /dev/null +++ b/src/Request/BuyItemRequest.php @@ -0,0 +1,43 @@ +item = $item; + $this->moneyCollection = $moneyCollection; + } + + /** + * @return MoneyCollection + */ + public function moneyCollection(): MoneyCollection + { + return $this->moneyCollection; + } + + /** + * @return Item + */ + public function item(): Item + { + return $this->item; + } +} From 5ee6cb69c7a9448b10f1b286b80e04f275a4d8ee Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 20:19:47 +0200 Subject: [PATCH 37/87] feat: implementation for simple Request interface --- src/Request/Request.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/Request/Request.php diff --git a/src/Request/Request.php b/src/Request/Request.php new file mode 100644 index 0000000..0d55ccc --- /dev/null +++ b/src/Request/Request.php @@ -0,0 +1,10 @@ + Date: Mon, 13 Apr 2020 20:20:14 +0200 Subject: [PATCH 38/87] feat: ConsoleRequest - use MoneyCollection --- src/Request/ConsoleRequest.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index ec1fd30..03524df 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -5,13 +5,11 @@ namespace VendingMachine\Request; use VendingMachine\Model\Money; +use VendingMachine\Model\MoneyCollection; class ConsoleRequest implements Request { - /** - * @var array Money[] - */ - private array $money = []; + private MoneyCollection $moneys; /** * @var string @@ -23,6 +21,7 @@ public function __construct(string $action) $this->assertAction($action); $this->action = $action; + $this->moneys = new MoneyCollection([]); } /** @@ -30,15 +29,15 @@ public function __construct(string $action) */ public function addMoney(Money $money): void { - $this->money[] = $money; + $this->moneys->addMoney($money); } /** - * @param Money[] + * @param MoneyCollection $moneys */ - public function setMoney(array $moneys): void + public function setMoney(MoneyCollection $moneys): void { - $this->money = $moneys; + $this->moneys = $moneys; } /** @@ -58,6 +57,11 @@ public function action(): string public function money(): array { - return $this->money; + return $this->moneys->money(); + } + + public function moneyCollection(): MoneyCollection + { + return $this->moneys; } } From fe3c53cea75bbee7e26c6548c36dc68ccc02025f Mon Sep 17 00:00:00 2001 From: Martin89PL Date: Mon, 13 Apr 2020 20:20:46 +0200 Subject: [PATCH 39/87] feat: Item list, method to valid money to buy item --- src/Item/ItemsInSale.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/Item/ItemsInSale.php diff --git a/src/Item/ItemsInSale.php b/src/Item/ItemsInSale.php new file mode 100644 index 0000000..d52a9cb --- /dev/null +++ b/src/Item/ItemsInSale.php @@ -0,0 +1,17 @@ + Date: Mon, 10 Jan 2022 07:39:18 +0100 Subject: [PATCH 40/87] fix: first commit from 13/04/2020 with tests fixes --- docker-compose.yml | 1 - src/Command/BuyItemCommand.php | 2 +- src/Item/Item.php | 5 +++++ tests/Factory/CommandFactoryTest.php | 2 +- tests/Item/ItemTest.php | 22 +++++++++++++-------- tests/Request/ConsoleRequestTest.php | 2 +- tests/VendingMachine/VendingMachineTest.php | 15 ++++++++++---- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1439af8..aed2fb9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,5 +5,4 @@ services: container_name: vending_machine volumes: - .:/usr/src/app - - /usr/src/app/vendor command: ["make", "check"] diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index 0ffa00a..e844fac 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -47,7 +47,7 @@ public function execute(BuyItemRequest $request): ConsoleResponse throw new \InvalidArgumentException(sprintf('Item %s is not available', $item->selector())); } - if ($item->enougthToBuy($moneys->count())) { + if ($item->enoughToBuy($moneys->count())) { $rest = $this->paymentCoordinator->pay($moneys->count(), $availableItem->value()); return $this->response->setRest($rest); } diff --git a/src/Item/Item.php b/src/Item/Item.php index dc54efe..1eb3f4e 100644 --- a/src/Item/Item.php +++ b/src/Item/Item.php @@ -24,4 +24,9 @@ public function equalsBySelector(string $selector): bool { return $this->selector === $selector; } + + public function enoughToBuy(int $count): bool + { + return $count >= $this->value; + } } diff --git a/tests/Factory/CommandFactoryTest.php b/tests/Factory/CommandFactoryTest.php index dc97786..5ea83ab 100644 --- a/tests/Factory/CommandFactoryTest.php +++ b/tests/Factory/CommandFactoryTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests; +namespace Tests\Factory; use PHPUnit\Framework\TestCase; use VendingMachine\Command\BuyItemCommand; diff --git a/tests/Item/ItemTest.php b/tests/Item/ItemTest.php index 6fc202f..27ebb12 100644 --- a/tests/Item/ItemTest.php +++ b/tests/Item/ItemTest.php @@ -9,24 +9,30 @@ class ItemTest extends TestCase { - public function testShouldReturnValue(): void + private ItemA $item; + + protected function setUp() { - $itemA = new ItemA(); + $this->item = new ItemA(); + } - self::assertEquals(65, $itemA->value()); + public function testShouldReturnValue(): void + { + self::assertEquals(65, $this->item->value()); } public function testShouldReturnSelector(): void { - $itemA = new ItemA(); - - self::assertEquals('A', $itemA->selector()); + self::assertEquals('A', $this->item->selector()); } public function testShouldReturnTrueWhenItemEquals(): void { - $itemA = new ItemA(); + self::assertTrue($this->item->equalsBySelector('A')); + } - self::assertTrue($itemA->equalsBySelector('A')); + public function testShouldTestIfEnoughMoneyToBuyItem(): void + { + self::assertFalse($this->item->enoughToBuy(10)); } } diff --git a/tests/Request/ConsoleRequestTest.php b/tests/Request/ConsoleRequestTest.php index 765a8fb..8b0878a 100644 --- a/tests/Request/ConsoleRequestTest.php +++ b/tests/Request/ConsoleRequestTest.php @@ -22,7 +22,7 @@ public function testShouldReturnAction(): void public function testShouldThrowInvalidArgumentExceptionWhenActionNameIsInvalid(): void { - self::expectException(\InvalidArgumentException::class); + $this->expectException(\InvalidArgumentException::class); new ConsoleRequest('test'); } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 92c2cb8..0a1605e 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -4,8 +4,11 @@ namespace Tests\VendingMachine; -use VendingMachine\VendingMachine; +use LogicException; use PHPUnit\Framework\TestCase; +use VendingMachine\Repository\ItemRepository; +use VendingMachine\Util\ConsoleInputParser; +use VendingMachine\VendingMachine; final class VendingMachineTest extends TestCase { @@ -14,11 +17,15 @@ final class VendingMachineTest extends TestCase public function setUp(): void { - $this->vendingMachine = new VendingMachine(); + $itemRepositoryMock = $this->getMockBuilder(ItemRepository::class)->getMock(); + + $this->vendingMachine = new VendingMachine($itemRepositoryMock, new ConsoleInputParser()); } - public function testServiceReturnsNoService(): void + public function testShouldThrowAnExceptionWhenNoActionFound(): void { - $this->assertEquals('test', $this->vendingMachine->execute('test')); + $this->expectException(LogicException::class); + + $this->vendingMachine->execute('test'); } } From 46b2fa69c0cb5dc7bc5cf6db878e45074dde96e0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 10:27:51 +0100 Subject: [PATCH 41/87] test: working with parsing tests, extends for more examples --- src/prompt.php | 1 - tests/Util/InputParserTest.php | 38 ++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/prompt.php b/src/prompt.php index 4152068..87d18de 100644 --- a/src/prompt.php +++ b/src/prompt.php @@ -9,7 +9,6 @@ use VendingMachine\Util\ConsoleInputParser; use VendingMachine\VendingMachine; - $itemRepository = new InMemoryItemRepository(); $itemRepository->add(new ItemB()); diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index fd93379..4706a06 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -11,12 +11,9 @@ class InputParserTest extends TestCase { - /** - * @var ConsoleInputParser - */ private ConsoleInputParser $parser; - protected function setUp() + protected function setUp(): void { $this->parser = new ConsoleInputParser(); } @@ -35,19 +32,30 @@ public function testShouldParseInputAndReturnConsoleRequestWithActionGet(): void self::assertEquals('GET-B', $request->action()); } - public function testShouldParseInputAndReturnConsoleRequestWith4QuarterMoney(): void + /** + * @return void + * @dataProvider dataSetForParsingMoney + */ + public function testShouldParseInputAndReturnConsoleRequestWithCorrectMoney(string $input, array $output): void { - $request = $this->parser->parse('Q, Q, Q, Q, GET-B'); - - self::assertEquals( - [ - new Quarter(), - new Quarter(), - new Quarter(), - new Quarter(), - ], - $request->money() + $output, + ($this->parser->parse($input))->money() ); } + + public function dataSetForParsingMoney(): array + { + return [ + [ + 'input' => 'Q, Q, Q, Q, GET-B', + 'output' => [ + new Quarter(), + new Quarter(), + new Quarter(), + new Quarter(), + ], + ] + ]; + } } From ef0840e4b27b7dd83c733d514542f35afef368f7 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:30:44 +0100 Subject: [PATCH 42/87] tests: add two test cases to parser test --- tests/Util/InputParserTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index 4706a06..6ff29bd 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -5,6 +5,8 @@ namespace Tests\Util; use PHPUnit\Framework\TestCase; +use VendingMachine\Model\Dollar; +use VendingMachine\Model\Nickel; use VendingMachine\Model\Quarter; use VendingMachine\Request\ConsoleRequest; use VendingMachine\Util\ConsoleInputParser; @@ -55,7 +57,16 @@ public function dataSetForParsingMoney(): array new Quarter(), new Quarter(), ], + ], + [ + 'input' => 'Q, GET-B', + 'output' => [new Quarter()] + ], + [ + 'input' => 'N, GET-B', + 'output' => [new Nickel()] ] + ]; } } From 42721518a4eb8609cd7f37a2c0e93b98da4a3a51 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:31:07 +0100 Subject: [PATCH 43/87] ref: remove type annotation --- src/Command/BuyItemCommand.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index e844fac..4e08dc1 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -11,19 +11,10 @@ class BuyItemCommand { - /** - * @var ItemRepository - */ private ItemRepository $itemRepository; - /** - * @var PaymentCoordinator - */ private PaymentCoordinator $paymentCoordinator; - /** - * @var ConsoleResponse - */ private ConsoleResponse $response; public function __construct( From 95581fe23643a3a9efc8fc6f0534b680fd5c3c4f Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:31:28 +0100 Subject: [PATCH 44/87] ref: add comments about new class instances --- src/Util/ConsoleInputParser.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php index c0f6c0e..cddd5a3 100644 --- a/src/Util/ConsoleInputParser.php +++ b/src/Util/ConsoleInputParser.php @@ -16,10 +16,11 @@ public function parse(string $input): ConsoleRequest $parameters = $this->splitParameters($input); $action = $this->filterAction($parameters); + // code smelling $consoleRequest = new ConsoleRequest($action); $money = $this->filterMoney($parameters); - + // code smelling $consoleRequest->setMoney(new MoneyCollection($money)); return $consoleRequest; @@ -46,7 +47,7 @@ private function filterAction(array $parameters): string } if ($action === null) { - throw new \LogicException('No action found!'); + throw new \LogicException(sprintf('No action found for %s', ...$parameters)); } return $action; } From 6de56adcc29208928281860e9049c29412a772d6 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:39:23 +0100 Subject: [PATCH 45/87] tests: use data provider --- tests/Request/ConsoleRequestTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Request/ConsoleRequestTest.php b/tests/Request/ConsoleRequestTest.php index 8b0878a..7a66c8d 100644 --- a/tests/Request/ConsoleRequestTest.php +++ b/tests/Request/ConsoleRequestTest.php @@ -15,9 +15,19 @@ public function testShouldCorrectCreateRequest(): void self::assertInstanceOf(ConsoleRequest::class, new ConsoleRequest('GET-B')); } - public function testShouldReturnAction(): void + /** + * @dataProvider dataTestToParseAction + */ + public function testShouldReturnAction($input, $output): void { - self::assertEquals('GET-B', (new ConsoleRequest('GET-B'))->action()); + self::assertEquals($input, (new ConsoleRequest($output))->action()); + } + + public function dataTestToParseAction(): array + { + return [ + ['GET-B', 'GET-B'], + ]; } public function testShouldThrowInvalidArgumentExceptionWhenActionNameIsInvalid(): void From 0933322fdbad97e68f52e9ad439bc667062cb3d4 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:43:25 +0100 Subject: [PATCH 46/87] tests: add payment coordinator property --- tests/Coordinator/PaymentCoordinatorTest.php | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index 824b9bb..877400a 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -11,10 +11,16 @@ class PaymentCoordinatorTest extends TestCase { + private PaymentCoordinator $paymentCoordinator; + + protected function setUp(): void + { + $this->paymentCoordinator = new PaymentCoordinator(); + } + public function testShouldNotReturnAnyRest(): void { - $paymentCoordinator = new PaymentCoordinator(); - $rest = $paymentCoordinator->pay(100, 100); + $rest = $this->paymentCoordinator->pay(100, 100); self::assertEquals(0, $rest->count()); self::assertEquals([], $rest->money()); @@ -22,9 +28,7 @@ public function testShouldNotReturnAnyRest(): void public function testShouldReturnRestInTwoQuarter(): void { - $paymentCoordinator = new PaymentCoordinator(); - $rest = $paymentCoordinator->pay(100, 50); - + $rest = $this->paymentCoordinator->pay(100, 50); self::assertEquals(50, $rest->count()); self::assertEquals( @@ -38,8 +42,7 @@ public function testShouldReturnRestInTwoQuarter(): void public function testShouldReturnRestInTwoDime(): void { - $paymentCoordinator = new PaymentCoordinator(); - $rest = $paymentCoordinator->pay(70, 50); + $rest = $this->paymentCoordinator->pay(70, 50); self::assertEquals(20, $rest->count()); self::assertEquals( @@ -53,8 +56,7 @@ public function testShouldReturnRestInTwoDime(): void public function testShouldReturnRestInQuarterAndDime(): void { - $paymentCoordinator = new PaymentCoordinator(); - $rest = $paymentCoordinator->pay(100, 65); + $rest = $this->paymentCoordinator->pay(100, 65); self::assertEquals(35, $rest->count()); self::assertEquals( @@ -65,5 +67,4 @@ public function testShouldReturnRestInQuarterAndDime(): void $rest->money() ); } - } From 3d5d34c05fc77d679c8f732cd359cedef27f3fdd Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:47:15 +0100 Subject: [PATCH 47/87] tests: pay for product without any money --- src/Coordinator/PaymentCoordinator.php | 3 +-- tests/Coordinator/PaymentCoordinatorTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php index 152953d..7393f34 100644 --- a/src/Coordinator/PaymentCoordinator.php +++ b/src/Coordinator/PaymentCoordinator.php @@ -18,9 +18,8 @@ public function pay(int $input, int $cost): MoneyCollection $coinRest = $this->calculateRest($rest, $this->getCoins()); return new MoneyCollection($coinRest); } - + // add domain exception with information about passed values throw new \InvalidArgumentException('No enough money to pay for it!'); - } private function calculateRest(int $rest, array $coins): array diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index 877400a..91dde21 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -4,6 +4,7 @@ namespace Tests\Coordinator; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; use VendingMachine\Coordinator\PaymentCoordinator; use VendingMachine\Model\Dime; @@ -67,4 +68,11 @@ public function testShouldReturnRestInQuarterAndDime(): void $rest->money() ); } + + public function testTryToPayForProductWithoutAnyMoney(): void + { + $this->expectException(InvalidArgumentException::class); + + $this->paymentCoordinator->pay(0, 65); + } } From e6b148afb3ee72c5c5aab92db5ea382a7e5ef812 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:51:19 +0100 Subject: [PATCH 48/87] tests: next test to try for paying for product --- tests/Coordinator/PaymentCoordinatorTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index 91dde21..b61ec67 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -75,4 +75,11 @@ public function testTryToPayForProductWithoutAnyMoney(): void $this->paymentCoordinator->pay(0, 65); } + + public function testTryPayForProductWithNotEnoughMoney(): void + { + $this->expectException(InvalidArgumentException::class); + + $this->paymentCoordinator->pay(10, 65); + } } From e797f336c192315fb9fc8cc04d376c39500487f8 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 11:52:31 +0100 Subject: [PATCH 49/87] tests: test with minus value of money --- tests/Coordinator/PaymentCoordinatorTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index b61ec67..df92e27 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -82,4 +82,11 @@ public function testTryPayForProductWithNotEnoughMoney(): void $this->paymentCoordinator->pay(10, 65); } + + public function testShouldTestAbstractSituationWithPayingWithMinusMoney(): void + { + $this->expectException(InvalidArgumentException::class); + + $this->paymentCoordinator->pay(-10, 65); + } } From d7d11e631f6428a6c4770242bc3a161c6e42530d Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 12:02:51 +0100 Subject: [PATCH 50/87] ref: format --- src/Coordinator/PaymentCoordinator.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php index 7393f34..88483ce 100644 --- a/src/Coordinator/PaymentCoordinator.php +++ b/src/Coordinator/PaymentCoordinator.php @@ -28,7 +28,6 @@ private function calculateRest(int $rest, array $coins): array /** @var Money $coin */ foreach ($coins as $coin) { if ($coin->value() <= $rest) { - $multiplication = $rest / $coin->value(); $integerMultiplication = (int) $multiplication; @@ -49,15 +48,14 @@ private function calculateRest(int $rest, array $coins): array private function getCoins(): array { - $coins = array_filter(AvailableMoney::getMoney(), static function(Money $money) { + $coins = array_filter(AvailableMoney::getMoney(), static function (Money $money) { return $money instanceof Coin; }); // sort DESC - usort($coins, static function(Money $a, Money $b) { + usort($coins, static function (Money $a, Money $b) { return $a->value() < $b->value(); }); return $coins; } - } From 4f86bd170f805b364779044fd7e5c952d40ed103 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 12:03:09 +0100 Subject: [PATCH 51/87] ref: load autoload based on lang const --- src/prompt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prompt.php b/src/prompt.php index 87d18de..2a486f1 100644 --- a/src/prompt.php +++ b/src/prompt.php @@ -2,7 +2,7 @@ declare(strict_types=1); -require_once '../vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; use VendingMachine\Item\ItemB; use VendingMachine\Repository\InMemoryItemRepository; From bcb99f2dbab83955a6ec064154bb980d43681fef Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 12:04:46 +0100 Subject: [PATCH 52/87] ref: return console object, remove annotations --- src/VendingMachine.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/VendingMachine.php b/src/VendingMachine.php index 5298de6..3acf070 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -15,14 +15,8 @@ final class VendingMachine { - - /** - * @var ItemRepository - */ private ItemRepository $itemRepository; - /** - * @var InputParser - */ + private InputParser $inputParser; public function __construct(ItemRepository $itemRepository, InputParser $inputParser) @@ -31,22 +25,19 @@ public function __construct(ItemRepository $itemRepository, InputParser $inputPa $this->inputParser = $inputParser; } - public function execute(string $input): string + public function execute(string $input): ConsoleResponse { $request = $this->parseInput($input); $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); - $response = $buyCommand->execute( + return $buyCommand->execute( new BuyItemRequest(new ItemB(), $request->moneyCollection()) ); - - return $response->getOutput(); } private function parseInput(string $input): ConsoleRequest { - /** @var ConsoleRequest $request */ return $this->inputParser->parse($input); } } From 7840e5ff159b6e2b6ccfc53da3cafe802e64f4dd Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 12:10:00 +0100 Subject: [PATCH 53/87] ref: set product classes as final, add strict types --- src/Item/Item.php | 2 +- src/Item/ItemA.php | 2 +- src/Item/ItemB.php | 2 +- src/Item/ItemC.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Item/Item.php b/src/Item/Item.php index 1eb3f4e..fc9134b 100644 --- a/src/Item/Item.php +++ b/src/Item/Item.php @@ -1,6 +1,6 @@ Date: Sun, 16 Jan 2022 12:35:38 +0100 Subject: [PATCH 54/87] config: update php image to php:8.1, update dependencies --- Dockerfile | 2 +- composer.json | 2 +- docker-compose.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 454d3f8..52d9220 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-cli +FROM php:8.1-fpm RUN apt-get update && apt-get install --no-install-recommends -y \ wget \ diff --git a/composer.json b/composer.json index 9d82286..18e3494 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "require": { }, "require-dev": { - "phpunit/phpunit": "^7", + "phpunit/phpunit": "^9", "friendsofphp/php-cs-fixer": "^2.16", "squizlabs/php_codesniffer": "^3.5", "phpstan/phpstan": "^0.12.18" diff --git a/docker-compose.yml b/docker-compose.yml index aed2fb9..68207d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,4 @@ services: container_name: vending_machine volumes: - .:/usr/src/app - command: ["make", "check"] + command: ["make"] From c1b895261762b1d9b6397ce952be70db2bb128a5 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 12:39:16 +0100 Subject: [PATCH 55/87] config: commit lock file --- composer.lock | 3000 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 2128 insertions(+), 872 deletions(-) diff --git a/composer.lock b/composer.lock index 94d6ab7..d3d50e1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,33 +4,105 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "206f42f23f49e7c8a36d1d1c136c0010", + "content-hash": "7f1c454425718425faa5ba3388d0932e", "packages": [], "packages-dev": [ + { + "name": "composer/pcre", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "3d322d715c43a1ac36c7fe215fa59336265500f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/3d322d715c43a1ac36c7fe215fa59336265500f2", + "reference": "3d322d715c43a1ac36c7fe215fa59336265500f2", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/1.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-12-06T15:17:27+00:00" + }, { "name": "composer/semver", - "version": "1.5.1", + "version": "3.2.7", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" + "reference": "deac27056b57e46faf136fae7b449eeaa71661ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", - "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "url": "https://api.github.com/repos/composer/semver/zipball/deac27056b57e46faf136fae7b449eeaa71661ee", + "reference": "deac27056b57e46faf136fae7b449eeaa71661ee", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0" + "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5" + "phpstan/phpstan": "^0.12.54", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -66,28 +138,50 @@ "validation", "versioning" ], - "time": "2020-01-13T12:06:48+00:00" + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.2.7" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-04T09:57:54+00:00" }, { "name": "composer/xdebug-handler", - "version": "1.4.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7" + "reference": "0c1a3925ec58a4ec98e992b9c7d171e9e184be0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/1ab9842d69e64fb3a01be6b656501032d1b78cb7", - "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/0c1a3925ec58a4ec98e992b9c7d171e9e184be0a", + "reference": "0c1a3925ec58a4ec98e992b9c7d171e9e184be0a", "shasum": "" }, "require": { + "composer/pcre": "^1", "php": "^5.3.2 || ^7.0 || ^8.0", - "psr/log": "^1.0" + "psr/log": "^1 || ^2 || ^3" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0" }, "type": "library", "autoload": { @@ -110,37 +204,55 @@ "Xdebug", "performance" ], - "time": "2020-03-01T12:26:26+00:00" + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/2.0.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-04T17:06:45+00:00" }, { "name": "doctrine/annotations", - "version": "1.10.1", + "version": "1.13.2", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "5eb79f3dbdffed6544e1fc287572c0f462bd29bb" + "reference": "5b668aef16090008790395c02c893b1ba13f7e08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/5eb79f3dbdffed6544e1fc287572c0f462bd29bb", - "reference": "5eb79f3dbdffed6544e1fc287572c0f462bd29bb", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5b668aef16090008790395c02c893b1ba13f7e08", + "reference": "5b668aef16090008790395c02c893b1ba13f7e08", "shasum": "" }, "require": { "doctrine/lexer": "1.*", "ext-tokenizer": "*", - "php": "^7.1" + "php": "^7.1 || ^8.0", + "psr/cache": "^1 || ^2 || ^3" }, "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "^7.5" + "doctrine/cache": "^1.11 || ^2.0", + "doctrine/coding-standard": "^6.0 || ^8.1", + "phpstan/phpstan": "^0.12.20", + "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", + "symfony/cache": "^4.4 || ^5.2" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" @@ -173,44 +285,45 @@ } ], "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", + "homepage": "https://www.doctrine-project.org/projects/annotations.html", "keywords": [ "annotations", "docblock", "parser" ], - "time": "2020-04-02T12:33:25+00:00" + "support": { + "issues": "https://github.com/doctrine/annotations/issues", + "source": "https://github.com/doctrine/annotations/tree/1.13.2" + }, + "time": "2021-08-05T19:00:23+00:00" }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^8.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "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", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -224,45 +337,59 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "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", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" }, { "name": "doctrine/lexer", - "version": "1.2.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" + "reference": "9c50f840f257bbb941e6f4a0e94ccf5db5c3f76c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", - "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/9c50f840f257bbb941e6f4a0e94ccf5db5c3f76c", + "reference": "9c50f840f257bbb941e6f4a0e94ccf5db5c3f76c", "shasum": "" }, "require": { - "php": "^7.2" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpstan/phpstan": "^0.11.8", - "phpunit/phpunit": "^8.2" + "doctrine/coding-standard": "^9.0", + "phpstan/phpstan": "1.3", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.11" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" @@ -295,31 +422,49 @@ "parser", "php" ], - "time": "2019-10-30T14:39:59+00:00" + "support": { + "issues": "https://github.com/doctrine/lexer/issues", + "source": "https://github.com/doctrine/lexer/tree/1.2.2" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], + "time": "2022-01-12T08:27:12+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.16.1", + "version": "v2.19.3", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02" + "reference": "75ac86f33fab4714ea5a39a396784d83ae3b5ed8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c8afb599858876e95e8ebfcd97812d383fa23f02", - "reference": "c8afb599858876e95e8ebfcd97812d383fa23f02", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/75ac86f33fab4714ea5a39a396784d83ae3b5ed8", + "reference": "75ac86f33fab4714ea5a39a396784d83ae3b5ed8", "shasum": "" }, "require": { - "composer/semver": "^1.4", - "composer/xdebug-handler": "^1.2", + "composer/semver": "^1.4 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^1.2 || ^2.0", "doctrine/annotations": "^1.2", "ext-json": "*", "ext-tokenizer": "*", - "php": "^5.6 || ^7.0", + "php": "^5.6 || ^7.0 || ^8.0", "php-cs-fixer/diff": "^1.3", - "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/console": "^3.4.43 || ^4.1.6 || ^5.0", "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", "symfony/finder": "^3.0 || ^4.0 || ^5.0", @@ -330,21 +475,24 @@ "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", "justinrainbow/json-schema": "^5.0", - "keradus/cli-executor": "^1.2", + "keradus/cli-executor": "^1.4", "mikey179/vfsstream": "^1.6", - "php-coveralls/php-coveralls": "^2.1", + "php-coveralls/php-coveralls": "^2.4.2", "php-cs-fixer/accessible-object": "^1.0", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", - "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", - "phpunitgoodpractices/traits": "^1.8", - "symfony/phpunit-bridge": "^4.3 || ^5.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy-phpunit": "^1.1 || ^2.0", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.5", + "phpunitgoodpractices/polyfill": "^1.5", + "phpunitgoodpractices/traits": "^1.9.1", + "sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1", + "symfony/phpunit-bridge": "^5.2.1", "symfony/yaml": "^3.0 || ^4.0 || ^5.0" }, "suggest": { - "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters.", "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." @@ -353,6 +501,11 @@ "php-cs-fixer" ], "type": "application", + "extra": { + "branch-alias": { + "dev-master": "2.19-dev" + } + }, "autoload": { "psr-4": { "PhpCsFixer\\": "src/" @@ -366,6 +519,8 @@ "tests/Test/IntegrationCaseFactory.php", "tests/Test/IntegrationCaseFactoryInterface.php", "tests/Test/InternalIntegrationCaseFactory.php", + "tests/Test/IsIdenticalConstraint.php", + "tests/Test/TokensWithObservedTransformers.php", "tests/TestCase.php" ] }, @@ -384,24 +539,34 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2019-11-25T22:10:32+00:00" + "support": { + "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.19.3" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2021-11-15T17:17:55+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.8.1", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -432,77 +597,99 @@ "object", "object graph" ], - "time": "2018-06-11T23:09:50+00:00" + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" }, { - "name": "paragonie/random_compat", - "version": "v9.99.99", + "name": "nikic/php-parser", + "version": "v4.13.2", "source": { "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077", "shasum": "" }, "require": { - "php": "^7" + "ext-tokenizer": "*", + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, + "bin": [ + "bin/php-parse" + ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" + "name": "Nikita Popov" } ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "description": "A PHP parser written in PHP", "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" + "parser", + "php" ], - "time": "2018-07-02T15:55:56+00:00" + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + }, + "time": "2021-11-30T19:35:32+00:00" }, { "name": "phar-io/manifest", - "version": "1.0.1", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", - "phar-io/version": "^1.0.1", - "php": "^5.6 || ^7.0" + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -532,24 +719,28 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-03-05T18:14:27+00:00" + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" }, { "name": "phar-io/version", - "version": "1.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + "reference": "bae7c545bef187884426f042434e561ab1ddb182" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -579,27 +770,31 @@ } ], "description": "Library for handling version information and constraints", - "time": "2017-03-05T17:38:23+00:00" + "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": "php-cs-fixer/diff", - "version": "v1.3.0", + "version": "v1.3.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/diff.git", - "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", - "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/dbd31aeb251639ac0b9e7e29405c1441907f5759", + "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", "symfony/process": "^3.3" }, "type": "library", @@ -613,14 +808,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, { "name": "SpacePossum" } @@ -630,39 +825,38 @@ "keywords": [ "diff" ], - "time": "2018-02-15T16:58:55+00:00" + "support": { + "issues": "https://github.com/PHP-CS-Fixer/diff/issues", + "source": "https://github.com/PHP-CS-Fixer/diff/tree/v1.3.1" + }, + "time": "2020-10-14T08:39:05+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -684,44 +878,46 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "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": "4.3.0", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -732,44 +928,50 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + }, + "time": "2021-10-19T17:43:47+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "*", + "psalm/phar": "^4.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -782,42 +984,47 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" + }, + "time": "2022-01-04T19:58:01+00:00" }, { "name": "phpspec/prophecy", - "version": "1.7.6", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" + "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", - "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", + "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "doctrine/instantiator": "^1.2", + "php": "^7.2 || ~8.0, <8.2", + "phpdocumentor/reflection-docblock": "^5.2", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + "phpspec/phpspec": "^6.0 || ^7.0", + "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -845,69 +1052,31 @@ "spy", "stub" ], - "time": "2018-04-18T13:57:24+00:00" - }, - { - "name": "phpstan/extension-installer", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "2e041def501d661b806f50000c8a4dccbd4907b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/2e041def501d661b806f50000c8a4dccbd4907b4", - "reference": "2e041def501d661b806f50000c8a4dccbd4907b4", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.1 || ^2.0", - "php": "^7.1", - "phpstan/phpstan": ">=0.11.6" - }, - "require-dev": { - "composer/composer": "^1.8", - "consistence/coding-standard": "^3.8", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^1.0", - "phing/phing": "^2.16", - "phpstan/phpstan-strict-rules": "^0.11", - "slevomat/coding-standard": "^5.0.4" - }, - "type": "composer-plugin", - "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" - }, - "autoload": { - "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" - } + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Composer plugin for automatic installation of PHPStan extensions", - "time": "2020-03-31T16:00:42+00:00" + "time": "2021-12-08T12:19:24+00:00" }, { "name": "phpstan/phpstan", - "version": "0.12.18", + "version": "0.12.99", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "1ce27fe29c8660a27926127d350d53d80c4d4286" + "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ce27fe29c8660a27926127d350d53d80c4d4286", - "reference": "1ce27fe29c8660a27926127d350d53d80c4d4286", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", + "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" }, "bin": [ "phpstan", @@ -929,202 +1098,195 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-03-22T16:51:47+00:00" + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2021-09-12T20:09:55+00:00" }, { - "name": "phpstan/phpstan-deprecation-rules", - "version": "0.12.2", + "name": "phpunit/php-code-coverage", + "version": "9.2.10", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "51d21a83b97e539e1fc56c1ce42ac0f187407fb6" + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/51d21a83b97e539e1fc56c1ce42ac0f187407fb6", - "reference": "51d21a83b97e539e1fc56c1ce42ac0f187407fb6", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "shasum": "" }, "require": { - "php": "~7.1", - "phpstan/phpstan": "^0.12" + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.13.0", + "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", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "consistence/coding-standard": "^3.0.1", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "jakub-onderka/php-parallel-lint": "^1.0", - "localheinz/composer-normalize": "^1.3.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.5.2" + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" }, - "type": "phpstan-extension", + "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "rules.neon" - ] + "dev-master": "9.2-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", - "time": "2020-01-12T16:25:40+00:00" + "time": "2021-12-05T09:12:13+00:00" }, { - "name": "phpstan/phpstan-phpunit", - "version": "0.12.6", + "name": "phpunit/php-file-iterator", + "version": "3.0.6", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "26394996368b6d033d012547d3197f4e07e23021" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/26394996368b6d033d012547d3197f4e07e23021", - "reference": "26394996368b6d033d012547d3197f4e07e23021", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { - "php": "~7.1", - "phpstan/phpstan": "^0.12.4" - }, - "conflict": { - "phpunit/phpunit": "<7.0" + "php": ">=7.3" }, "require-dev": { - "consistence/coding-standard": "^3.5", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^1.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^7.0", - "satooshi/php-coveralls": "^1.0", - "slevomat/coding-standard": "^4.7.2" - }, - "type": "phpstan-extension", + "phpunit/phpunit": "^9.3" + }, + "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "extension.neon", - "rules.neon" - ] + "dev-master": "3.0-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "description": "PHPUnit extensions and rules for PHPStan", - "time": "2020-01-10T12:07:21+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { - "name": "phpstan/phpstan-strict-rules", - "version": "0.12.2", + "name": "phpunit/php-invoker", + "version": "3.1.1", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "a670a59aff7cf96f75d21b974860ada10e25b2ee" + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/a670a59aff7cf96f75d21b974860ada10e25b2ee", - "reference": "a670a59aff7cf96f75d21b974860ada10e25b2ee", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", "shasum": "" }, "require": { - "php": "~7.1", - "phpstan/phpstan": "^0.12.6" + "php": ">=7.3" }, "require-dev": { - "consistence/coding-standard": "^3.0.1", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^1.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.5.2" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Extra strict and opinionated rules for PHPStan", - "time": "2020-01-20T13:08:52+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "6.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/865662550c384bc1db7e51d29aeda1c2c161d69a", - "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-xdebug": "^2.6.0" + "ext-pcntl": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1143,80 +1305,49 @@ "role": "lead" } ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", "keywords": [ - "coverage", - "testing", - "xunit" + "process" ], - "time": "2018-06-01T07:51:50+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cecbc684605bb0cc288828eb5d65d93d5c676d3c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cecbc684605bb0cc288828eb5d65d93d5c676d3c", - "reference": "cecbc684605bb0cc288828eb5d65d93d5c676d3c", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + "funding": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2018-06-11T11:44:00+00:00" + "time": "2020-09-28T05:58:55+00:00" }, { "name": "phpunit/php-text-template", - "version": "1.2.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1238,32 +1369,42 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" }, { "name": "phpunit/php-timer", - "version": "2.0.0", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1287,38 +1428,85 @@ "keywords": [ "timer" ], - "time": "2018-02-01T13:07:23+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" }, { - "name": "phpunit/php-token-stream", - "version": "3.0.0", + "name": "phpunit/phpunit", + "version": "9.5.11", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "2406855036db1102126125537adb1406f7242fdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", - "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2406855036db1102126125537adb1406f7242fdd", + "reference": "2406855036db1102126125537adb1406f7242fdd", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "php": "^7.1" + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.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.7", + "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.4", + "sebastian/version": "^3.0.2" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "9.5-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1328,121 +1516,103 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", "keywords": [ - "tokenizer" + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.11" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2018-02-01T13:16:43+00:00" + "time": "2021-12-25T07:07:57+00:00" }, { - "name": "phpunit/phpunit", - "version": "7.2.6", + "name": "psr/cache", + "version": "3.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "400a3836ee549ae6f665323ac3f21e27eac7155f" + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/400a3836ee549ae6f665323ac3f21e27eac7155f", - "reference": "400a3836ee549ae6f665323ac3f21e27eac7155f", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.1", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.1", - "phar-io/version": "^1.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.0", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^3.1", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^1.0", - "sebastian/version": "^2.0.1" - }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" + "php": ">=8.0.0" }, - "bin": [ - "phpunit" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "7.2-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "Psr\\Cache\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" } ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", + "description": "Common interface for caching libraries", "keywords": [ - "phpunit", - "testing", - "xunit" + "cache", + "psr", + "psr-6" ], - "time": "2018-06-21T13:13:39+00:00" + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" }, { "name": "psr/container", - "version": "1.0.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1457,7 +1627,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -1469,7 +1639,11 @@ "container-interop", "psr" ], - "time": "2017-02-14T16:28:37+00:00" + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/event-dispatcher", @@ -1515,34 +1689,38 @@ "psr", "psr-14" ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, "time": "2019-01-08T18:20:26+00:00" }, { "name": "psr/log", - "version": "1.1.3", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1552,7 +1730,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", @@ -1562,32 +1740,35 @@ "psr", "psr-3" ], - "time": "2020-03-23T09:12:05+00:00" + "support": { + "source": "https://github.com/php-fig/log/tree/2.0.0" + }, + "time": "2021-07-14T16:41:46+00:00" }, { - "name": "sebastian/code-unit-reverse-lookup", + "name": "sebastian/cli-parser", "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -1602,39 +1783,48 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "description": "Library for parsing CLI options", + "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" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" }, { - "name": "sebastian/comparator", - "version": "3.0.1", + "name": "sebastian/code-unit", + "version": "1.0.8", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "591a30922f54656695e59b1f39501aec513403da" + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/591a30922f54656695e59b1f39501aec513403da", - "reference": "591a30922f54656695e59b1f39501aec513403da", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", "shasum": "" }, "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -1647,57 +1837,50 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" + "description": "Collection of value objects that represent the PHP code units", + "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" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2018-06-14T15:05:28+00:00" + "time": "2020-10-26T13:08:54+00:00" }, { - "name": "sebastian/diff", - "version": "3.0.1", + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "366541b989927187c4ca70490a35615d3fef2dce" + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", - "reference": "366541b989927187c4ca70490a35615d3fef2dce", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.0", - "symfony/process": "^2 || ^3.3 || ^4" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1710,49 +1893,51 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2018-06-10T07:54:39+00:00" + "time": "2020-09-28T05:30:19+00:00" }, { - "name": "sebastian/environment", - "version": "3.1.0", + "name": "sebastian/comparator", + "version": "4.0.6", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1768,43 +1953,251 @@ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" } ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:49:45+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ "Xdebug", "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:52:38+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1817,6 +2210,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1825,46 +2222,55 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "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" ], - "time": "2017-04-03T13:19:02+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-11-11T14:18:36+00:00" }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-uopz": "*" @@ -1872,7 +2278,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1895,34 +2301,101 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-11T13:31:12+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.6", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "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" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" }, { "name": "sebastian/object-enumerator", - "version": "3.0.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1942,32 +2415,42 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1987,32 +2470,42 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2025,14 +2518,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "name": "Adam Harvey", "email": "aharvey@php.net" @@ -2040,29 +2533,42 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:17:30+00:00" }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2082,29 +2588,95 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "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" + }, + { + "name": "sebastian/type", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-15T12:49:02+00:00" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=7.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2125,20 +2697,30 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.4", + "version": "3.6.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dceec07328401de6211037abbb18bda423677e26" + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", - "reference": "dceec07328401de6211037abbb18bda423677e26", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", "shasum": "" }, "require": { @@ -2176,45 +2758,55 @@ "phpcs", "standards" ], - "time": "2020-01-30T22:20:29+00:00" + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" }, { "name": "symfony/console", - "version": "v5.0.7", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935" + "reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", - "reference": "5fa1caadc8cdaa17bcfb25219f3b53fe294a9935", + "url": "https://api.github.com/repos/symfony/console/zipball/a2c6b7ced2eb7799a35375fb9022519282b5405e", + "reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1|^2" + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" }, "conflict": { + "psr/log": ">=3", "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", "symfony/lock": "<4.4", "symfony/process": "<4.4" }, "provide": { - "psr/log-implementation": "1.0" + "psr/log-implementation": "1.0|2.0" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/event-dispatcher": "^4.4|^5.0", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^4.4|^5.0", - "symfony/var-dumper": "^4.4|^5.0" + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -2223,11 +2815,6 @@ "symfony/process": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" @@ -2250,27 +2837,119 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Console Component", + "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", - "time": "2020-03-30T11:42:42+00:00" + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.4.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-20T16:11:12+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "shasum": "" + }, + "require": { + "php": ">=8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.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-11-01T23:48:49+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.0.7", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc" + "reference": "27d39ae126352b9fa3be5e196ccf4617897be3eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/24f40d95385774ed5c71dbf014edd047e2f2f3dc", - "reference": "24f40d95385774ed5c71dbf014edd047e2f2f3dc", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/27d39ae126352b9fa3be5e196ccf4617897be3eb", + "reference": "27d39ae126352b9fa3be5e196ccf4617897be3eb", "shasum": "" }, "require": { - "php": "^7.2.5", - "symfony/event-dispatcher-contracts": "^2" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/event-dispatcher-contracts": "^2|^3", + "symfony/polyfill-php80": "^1.16" }, "conflict": { "symfony/dependency-injection": "<4.4" @@ -2280,24 +2959,20 @@ "symfony/event-dispatcher-implementation": "2.0" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", - "symfony/service-contracts": "^1.1|^2", - "symfony/stopwatch": "^4.4|^5.0" + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^4.4|^5.0|^6.0" }, "suggest": { "symfony/dependency-injection": "", "symfony/http-kernel": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" @@ -2320,26 +2995,43 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony EventDispatcher Component", + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", - "time": "2020-03-27T16:56:45+00:00" + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.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-11-23T10:19:22+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.0.1", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "af23c2584d4577d54661c434446fb8fbed6025dd" + "reference": "aa5422287b75594b90ee9cd807caf8f0df491385" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/af23c2584d4577d54661c434446fb8fbed6025dd", - "reference": "af23c2584d4577d54661c434446fb8fbed6025dd", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/aa5422287b75594b90ee9cd807caf8f0df491385", + "reference": "aa5422287b75594b90ee9cd807caf8f0df491385", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=8.0.2", "psr/event-dispatcher": "^1" }, "suggest": { @@ -2348,7 +3040,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2380,32 +3076,46 @@ "interoperability", "standards" ], - "time": "2019-11-18T17:27:11+00:00" + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.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-07-15T12:33:35+00:00" }, { "name": "symfony/filesystem", - "version": "v5.0.7", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "ca3b87dd09fff9b771731637f5379965fbfab420" + "reference": "731f917dc31edcffec2c6a777f3698c33bea8f01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/ca3b87dd09fff9b771731637f5379965fbfab420", - "reference": "ca3b87dd09fff9b771731637f5379965fbfab420", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/731f917dc31edcffec2c6a777f3698c33bea8f01", + "reference": "731f917dc31edcffec2c6a777f3698c33bea8f01", "shasum": "" }, "require": { - "php": "^7.2.5", - "symfony/polyfill-ctype": "~1.8" + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Filesystem\\": "" @@ -2428,33 +3138,47 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Filesystem Component", + "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", - "time": "2020-03-27T16:56:45+00:00" + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.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-10-28T13:39:27+00:00" }, { "name": "symfony/finder", - "version": "v5.0.7", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d" + "reference": "e77046c252be48c48a40816187ed527703c8f76c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/600a52c29afc0d1caa74acbec8d3095ca7e9910d", - "reference": "600a52c29afc0d1caa74acbec8d3095ca7e9910d", + "url": "https://api.github.com/repos/symfony/finder/zipball/e77046c252be48c48a40816187ed527703c8f76c", + "reference": "e77046c252be48c48a40816187ed527703c8f76c", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Finder\\": "" @@ -2477,39 +3201,214 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Finder Component", + "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", - "time": "2020-03-27T16:56:45+00:00" + "support": { + "source": "https://github.com/symfony/finder/tree/v5.4.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-15T11:06:13+00:00" }, { "name": "symfony/options-resolver", - "version": "v5.0.7", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d" + "reference": "b0fb78576487af19c500aaddb269fd36701d4847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/09dccfffd24b311df7f184aa80ee7b61ad61ed8d", - "reference": "09dccfffd24b311df7f184aa80ee7b61ad61ed8d", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/b0fb78576487af19c500aaddb269fd36701d4847", + "reference": "b0fb78576487af19c500aaddb269fd36701d4847", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php73": "~1.0", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v5.4.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-11-23T10:19:22+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "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.24.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-10-20T20:35:02+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.24.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" }, - "exclude-from-classmap": [ - "/Tests/" + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2518,55 +3417,82 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony OptionsResolver Component", + "description": "Symfony polyfill for intl's grapheme_* functions", "homepage": "https://symfony.com", "keywords": [ - "config", - "configuration", - "options" + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.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": "2020-03-27T16:56:45+00:00" + "time": "2021-11-23T21:10:46+00:00" }, { - "name": "symfony/polyfill-ctype", - "version": "v1.15.0", + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14" + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14", - "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { - "ext-ctype": "For best performance" + "ext-intl": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" }, "files": [ "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2575,40 +3501,62 @@ ], "authors": [ { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for ctype functions", + "description": "Symfony polyfill for intl's Normalizer class and related functions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "ctype", + "intl", + "normalizer", "polyfill", - "portable" + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.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": "2020-02-27T09:26:54+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.15.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" }, "suggest": { "ext-mbstring": "For best performance" @@ -2616,7 +3564,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2650,42 +3602,51 @@ "portable", "shim" ], - "time": "2020-03-09T19:04:49+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.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-11-30T18:21:41+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.15.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "2a18e37a489803559284416df58c71ccebe50bf0" + "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/2a18e37a489803559284416df58c71ccebe50bf0", - "reference": "2a18e37a489803559284416df58c71ccebe50bf0", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/5f03a781d984aae42cebd18e7912fa80f02ee644", + "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644", "shasum": "" }, "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" + "php": ">=7.1" }, - "type": "library", + "type": "metapackage", "extra": { "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" + "dev-main": "1.20-dev" }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2709,29 +3670,50 @@ "portable", "shim" ], - "time": "2020-02-27T09:26:54+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-php70/tree/v1.20.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": "2020-10-23T14:02:19+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.15.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "37b0976c78b94856543260ce09b460a7bc852747" + "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", - "reference": "37b0976c78b94856543260ce09b460a7bc852747", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", + "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2764,29 +3746,50 @@ "portable", "shim" ], - "time": "2020-02-27T09:26:54+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-php72/tree/v1.24.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-05-27T09:17:38+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.15.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7" + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", - "reference": "0f27e9f464ea3da33cbe7ca3bdf4eb66def9d0f7", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2822,31 +3825,127 @@ "portable", "shim" ], - "time": "2020-02-27T09:26:54+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.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-06-05T21:20:04+00:00" }, { - "name": "symfony/process", - "version": "v5.0.7", + "name": "symfony/polyfill-php80", + "version": "v1.24.0", "source": { "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", - "reference": "c5ca4a0fc16a0c888067d43fbcfe1f8a53d8e70e", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.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-09-13T13:58:33+00:00" + }, + { + "name": "symfony/process", + "version": "v5.4.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/2b3ba8722c4aaf3e88011be5e7f48710088fb5e4", + "reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" }, + "type": "library", "autoload": { "psr-4": { "Symfony\\Component\\Process\\": "" @@ -2869,27 +3968,47 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Process Component", + "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", - "time": "2020-03-27T16:56:45+00:00" + "support": { + "source": "https://github.com/symfony/process/tree/v5.4.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-27T21:01:00+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.0.1", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "144c5e51266b281231e947b51223ba14acf1a749" + "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749", - "reference": "144c5e51266b281231e947b51223ba14acf1a749", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603", + "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603", "shasum": "" }, "require": { - "php": "^7.2.5", - "psr/container": "^1.0" + "php": ">=8.0.2", + "psr/container": "^2.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2" }, "suggest": { "symfony/service-implementation": "" @@ -2897,7 +4016,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2929,32 +4052,44 @@ "interoperability", "standards" ], - "time": "2019-11-18T17:27:11+00:00" + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.0.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-11-04T17:53:12+00:00" }, { "name": "symfony/stopwatch", - "version": "v5.0.7", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73" + "reference": "208ef96122bfed82a8f3a61458a07113a08bdcfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/a1d86d30d4522423afc998f32404efa34fcf5a73", - "reference": "a1d86d30d4522423afc998f32404efa34fcf5a73", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/208ef96122bfed82a8f3a61458a07113a08bdcfe", + "reference": "208ef96122bfed82a8f3a61458a07113a08bdcfe", "shasum": "" }, "require": { - "php": "^7.2.5", - "symfony/service-contracts": "^1.0|^2" + "php": ">=7.2.5", + "symfony/service-contracts": "^1|^2|^3" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Stopwatch\\": "" @@ -2977,29 +4112,131 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Stopwatch Component", + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v5.4.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-11-23T10:19:22+00:00" + }, + { + "name": "symfony/string", + "version": "v6.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "bae261d0c3ac38a1f802b4dfed42094296100631" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/bae261d0c3ac38a1f802b4dfed42094296100631", + "reference": "bae261d0c3ac38a1f802b4dfed42094296100631", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.0" + }, + "require-dev": { + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", "homepage": "https://symfony.com", - "time": "2020-03-27T16:56:45+00:00" + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v6.0.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-12-16T22:13:01+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -3019,33 +4256,47 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2017-04-07T12:08:54+00:00" + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2021-07-28T10:34:58+00:00" }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.10.0", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "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": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^8.5.13" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.10-dev" } }, "autoload": { @@ -3069,7 +4320,11 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "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" } ], "aliases": [], @@ -3078,5 +4333,6 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.1.0" } From 41a50cd4bd4aa29a7e3f7fad2eca07af07413496 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 16 Jan 2022 12:39:42 +0100 Subject: [PATCH 56/87] ref: formatting of code, add test to test buy command --- src/Command/BuyItemCommand.php | 5 +++-- tests/Command/BuyItemCommandTest.php | 15 ++++++++++++++- tests/VendingMachine/VendingMachineTest.php | 3 +-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index 4e08dc1..655044d 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -39,8 +39,9 @@ public function execute(BuyItemRequest $request): ConsoleResponse } if ($item->enoughToBuy($moneys->count())) { - $rest = $this->paymentCoordinator->pay($moneys->count(), $availableItem->value()); - return $this->response->setRest($rest); + return $this->response->setRest( + $this->paymentCoordinator->pay($moneys->count(), $availableItem->value()) + ); } throw new \InvalidArgumentException('Set enough money to buy Item!'); diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php index 26c3f70..26dc1c8 100644 --- a/tests/Command/BuyItemCommandTest.php +++ b/tests/Command/BuyItemCommandTest.php @@ -12,7 +12,6 @@ use VendingMachine\Model\MoneyCollection; use VendingMachine\Repository\InMemoryItemRepository; use VendingMachine\Request\BuyItemRequest; -use VendingMachine\Request\ConsoleRequest; use VendingMachine\Response\ConsoleResponse; class BuyItemCommandTest extends TestCase @@ -30,4 +29,18 @@ public function testShouldReturnBoughtBItem(): void self::assertInstanceOf(ConsoleResponse::class, $result); } + + public function testShouldCalculateRestAndReturnResponseWithCorrectAmount(): void + { + $itemRepository = new InMemoryItemRepository(); + $itemRepository->add(new ItemB()); + + $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); + + $result = $buyItemCommand->execute( + new BuyItemRequest(new ItemB(), new MoneyCollection([new Dollar()])) + ); + + self::assertEquals(35, $result->rest()->count()); + } } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 0a1605e..40812fe 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -12,8 +12,7 @@ final class VendingMachineTest extends TestCase { - /** @var VendingMachine */ - private $vendingMachine; + private VendingMachine $vendingMachine; public function setUp(): void { From 7f5ae9d0ae1ccb05f51dd61fa4c8fe252a63d19c Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 16:52:55 +0100 Subject: [PATCH 57/87] config: update image to 8.1 --- Dockerfile | 8 ++++++-- docker-compose.yml | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 52d9220..d89b68f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm +FROM php:8.1 RUN apt-get update && apt-get install --no-install-recommends -y \ wget \ @@ -6,6 +6,10 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ git \ unzip +RUN pecl install xdebug && docker-php-ext-enable xdebug + +COPY ./.docker/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + COPY --from=composer /usr/bin/composer /usr/bin/composer RUN mkdir -p /usr/src/app @@ -16,4 +20,4 @@ WORKDIR /usr/src/app RUN composer install --no-interaction -CMD ["make"] +CMD ["/bin/bash"] diff --git a/docker-compose.yml b/docker-compose.yml index 68207d1..ce3df94 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,5 @@ services: container_name: vending_machine volumes: - .:/usr/src/app - command: ["make"] + environment: + - PHP_IDE_CONFIG=serverName=vending_machine \ No newline at end of file From 779c637bb0d71cb22a5488381fd023c6c68155bb Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 17:42:20 +0100 Subject: [PATCH 58/87] build: update on building environment using docker --- .dockerignore | 1 + Dockerfile | 10 +++++----- README.md | 9 ++++++--- docker-compose.yml | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a725465 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +vendor/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d89b68f..03a1a9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,16 +8,16 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ RUN pecl install xdebug && docker-php-ext-enable xdebug -COPY ./.docker/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - COPY --from=composer /usr/bin/composer /usr/bin/composer -RUN mkdir -p /usr/src/app +RUN mkdir -p /app -COPY composer.json /usr/src/app +COPY composer.* /app/ -WORKDIR /usr/src/app +WORKDIR /app RUN composer install --no-interaction +COPY . . + CMD ["/bin/bash"] diff --git a/README.md b/README.md index 04ecd06..b8f7514 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,15 @@ Instructions: https://code.joejag.com/coding-dojo/vending-machine/ Tests: `./vendor/bin/phpunit` -## Setup +### Setup Run commands: * `docker-compose up` -## Run +### Run Open interactive bash `docker-compose run --rm vending_machine bash` -## Development +### Development Copy dependencies form volume: `sudo docker cp vending_machine:/usr/src/app/vendor ./` + +### Run tests +`docker-composer run --rm vending_machine ./vendor/bin/phpunit` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ce3df94..a20fc95 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: build: . container_name: vending_machine volumes: - - .:/usr/src/app + - .:/app + - /app/vendor environment: - PHP_IDE_CONFIG=serverName=vending_machine \ No newline at end of file From d3464802c802af6f2f5cf2f68a30f11e0d0d5ca0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 17:58:35 +0100 Subject: [PATCH 59/87] build: possibility to install dependencies on host --- .dockerignore | 1 - README.md | 5 ++++- docker-compose.yml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index a725465..0000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -vendor/ \ No newline at end of file diff --git a/README.md b/README.md index b8f7514..c5e1b4c 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,8 @@ Open interactive bash `docker-compose run --rm vending_machine bash` ### Development Copy dependencies form volume: `sudo docker cp vending_machine:/usr/src/app/vendor ./` +### Install dependencies (to local developing) +`docker-compose run --rm vending_machine composer install` + ### Run tests -`docker-composer run --rm vending_machine ./vendor/bin/phpunit` \ No newline at end of file +`docker-compose run --rm vending_machine ./vendor/bin/phpunit` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a20fc95..8420aa5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,6 @@ services: container_name: vending_machine volumes: - .:/app - - /app/vendor + - ./vendor:/app/vendor environment: - PHP_IDE_CONFIG=serverName=vending_machine \ No newline at end of file From e45a1d918094e0484753691ccebde8172079eda0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 18:19:14 +0100 Subject: [PATCH 60/87] ref: fix phpunit errors --- src/Coordinator/PaymentCoordinator.php | 2 +- src/Model/MoneyCollection.php | 2 +- tests/Item/ItemTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php index 88483ce..192a375 100644 --- a/src/Coordinator/PaymentCoordinator.php +++ b/src/Coordinator/PaymentCoordinator.php @@ -53,7 +53,7 @@ private function getCoins(): array }); // sort DESC usort($coins, static function (Money $a, Money $b) { - return $a->value() < $b->value(); + return min($a->value(), $b->value()); }); return $coins; diff --git a/src/Model/MoneyCollection.php b/src/Model/MoneyCollection.php index 12b7dc5..ce56b74 100644 --- a/src/Model/MoneyCollection.php +++ b/src/Model/MoneyCollection.php @@ -32,7 +32,7 @@ public function money() /** * @inheritDoc */ - public function count() + public function count(): int { $sum = 0; diff --git a/tests/Item/ItemTest.php b/tests/Item/ItemTest.php index 27ebb12..ff4d243 100644 --- a/tests/Item/ItemTest.php +++ b/tests/Item/ItemTest.php @@ -11,7 +11,7 @@ class ItemTest extends TestCase { private ItemA $item; - protected function setUp() + protected function setUp(): void { $this->item = new ItemA(); } From 1c28aae9b130f3de69727fddc4e0aa9fafabe52d Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 18:23:10 +0100 Subject: [PATCH 61/87] ref: passing tests, two assertions commented, to fix --- tests/Command/BuyItemCommandTest.php | 2 +- tests/Coordinator/PaymentCoordinatorTest.php | 28 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php index 26dc1c8..7ae9593 100644 --- a/tests/Command/BuyItemCommandTest.php +++ b/tests/Command/BuyItemCommandTest.php @@ -41,6 +41,6 @@ public function testShouldCalculateRestAndReturnResponseWithCorrectAmount(): voi new BuyItemRequest(new ItemB(), new MoneyCollection([new Dollar()])) ); - self::assertEquals(35, $result->rest()->count()); + self::assertEquals(0, $result->rest()->count()); } } diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index df92e27..80c1667 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -32,13 +32,13 @@ public function testShouldReturnRestInTwoQuarter(): void $rest = $this->paymentCoordinator->pay(100, 50); self::assertEquals(50, $rest->count()); - self::assertEquals( - [ - new Quarter(), - new Quarter() - ], - $rest->money() - ); +// self::assertEquals( +// [ +// new Quarter(), +// new Quarter() +// ], +// $rest->money() +// ); } public function testShouldReturnRestInTwoDime(): void @@ -60,13 +60,13 @@ public function testShouldReturnRestInQuarterAndDime(): void $rest = $this->paymentCoordinator->pay(100, 65); self::assertEquals(35, $rest->count()); - self::assertEquals( - [ - new Quarter(), - new Dime() - ], - $rest->money() - ); +// self::assertEquals( +// [ +// new Quarter(), +// new Dime() +// ], +// $rest->money() +// ); } public function testTryToPayForProductWithoutAnyMoney(): void From 78881f34e4fd4e9d21faefe6c62b7602d57cff64 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 18:37:19 +0100 Subject: [PATCH 62/87] ref: fix sorting after 8.1 changes, all tests passed --- src/Coordinator/PaymentCoordinator.php | 7 +++-- src/Model/AvailableMoney.php | 10 ++++++- tests/Coordinator/PaymentCoordinatorTest.php | 28 ++++++++++---------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php index 192a375..17db433 100644 --- a/src/Coordinator/PaymentCoordinator.php +++ b/src/Coordinator/PaymentCoordinator.php @@ -48,12 +48,11 @@ private function calculateRest(int $rest, array $coins): array private function getCoins(): array { - $coins = array_filter(AvailableMoney::getMoney(), static function (Money $money) { - return $money instanceof Coin; - }); + $coins = AvailableMoney::coins(); + // sort DESC usort($coins, static function (Money $a, Money $b) { - return min($a->value(), $b->value()); + return ($a->value() > $b->value()) ? -1 : 1; }); return $coins; diff --git a/src/Model/AvailableMoney.php b/src/Model/AvailableMoney.php index 82555b2..da234ae 100644 --- a/src/Model/AvailableMoney.php +++ b/src/Model/AvailableMoney.php @@ -8,7 +8,6 @@ final class AvailableMoney { public static function getMoney(): array { - // @TODO load class from specific dir/namespace return [ new Nickel(), new Dime(), @@ -16,4 +15,13 @@ public static function getMoney(): array new Dollar() ]; } + + public static function coins() + { + return [ + new Nickel(), + new Dime(), + new Quarter(), + ]; + } } diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index 80c1667..df92e27 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -32,13 +32,13 @@ public function testShouldReturnRestInTwoQuarter(): void $rest = $this->paymentCoordinator->pay(100, 50); self::assertEquals(50, $rest->count()); -// self::assertEquals( -// [ -// new Quarter(), -// new Quarter() -// ], -// $rest->money() -// ); + self::assertEquals( + [ + new Quarter(), + new Quarter() + ], + $rest->money() + ); } public function testShouldReturnRestInTwoDime(): void @@ -60,13 +60,13 @@ public function testShouldReturnRestInQuarterAndDime(): void $rest = $this->paymentCoordinator->pay(100, 65); self::assertEquals(35, $rest->count()); -// self::assertEquals( -// [ -// new Quarter(), -// new Dime() -// ], -// $rest->money() -// ); + self::assertEquals( + [ + new Quarter(), + new Dime() + ], + $rest->money() + ); } public function testTryToPayForProductWithoutAnyMoney(): void From 0f7b9ac0f03d0fabf1841401a7d6e49b7f199157 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 18:42:11 +0100 Subject: [PATCH 63/87] tests: add assertion to MoneyCollection --- src/Model/MoneyCollection.php | 6 ------ tests/Model/MoneyCollectionTest.php | 4 ++++ tests/VendingMachine/VendingMachineTest.php | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Model/MoneyCollection.php b/src/Model/MoneyCollection.php index ce56b74..ffa6fee 100644 --- a/src/Model/MoneyCollection.php +++ b/src/Model/MoneyCollection.php @@ -21,17 +21,11 @@ public function addMoney(Money $money): void $this->money[] = $money; } - /** - * @return array|Money[] - */ public function money() { return $this->money; } - /** - * @inheritDoc - */ public function count(): int { $sum = 0; diff --git a/tests/Model/MoneyCollectionTest.php b/tests/Model/MoneyCollectionTest.php index 5603add..c369e6c 100644 --- a/tests/Model/MoneyCollectionTest.php +++ b/tests/Model/MoneyCollectionTest.php @@ -20,5 +20,9 @@ public function testShouldProperlySumMoney(): void ); self::assertEquals(50, $moneyCollection->count()); + self::assertEquals([ + new Quarter(), + new Quarter() + ], $moneyCollection->money()); } } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 40812fe..aea3afc 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -27,4 +27,6 @@ public function testShouldThrowAnExceptionWhenNoActionFound(): void $this->vendingMachine->execute('test'); } + + } From 36bbb38f95e234723f1df0750239816158df078d Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 18:52:52 +0100 Subject: [PATCH 64/87] tests: invalid case with parsing get input --- src/Command/BuyItemCommand.php | 4 +--- tests/VendingMachine/VendingMachineTest.php | 26 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index 655044d..d8b87e8 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -34,9 +34,7 @@ public function execute(BuyItemRequest $request): ConsoleResponse $availableItem = $this->itemRepository->getItemBySelector($item->selector()); - if ($availableItem === null) { - throw new \InvalidArgumentException(sprintf('Item %s is not available', $item->selector())); - } + if (!$availableItem) throw new \InvalidArgumentException(sprintf('Item %s is not available', $item->selector())); if ($item->enoughToBuy($moneys->count())) { return $this->response->setRest( diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index aea3afc..19a6765 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -6,6 +6,10 @@ use LogicException; use PHPUnit\Framework\TestCase; +use VendingMachine\Item\ItemA; +use VendingMachine\Item\ItemB; +use VendingMachine\Item\ItemC; +use VendingMachine\Repository\InMemoryItemRepository; use VendingMachine\Repository\ItemRepository; use VendingMachine\Util\ConsoleInputParser; use VendingMachine\VendingMachine; @@ -28,5 +32,27 @@ public function testShouldThrowAnExceptionWhenNoActionFound(): void $this->vendingMachine->execute('test'); } + public function testShouldOrderProductAndSpendAllMoney(): void + { + $repository = new InMemoryItemRepository(); + $repository->add(new ItemC()); + + $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); + + $response = $vendingMachine->execute('Q, Q, Q, Q, GET-C'); + + self::assertEquals(0 ,$response->rest()->count()); + } + public function testShouldOrderProductAndGetRest(): void + { + $repository = new InMemoryItemRepository(); + $repository->add(new ItemA()); + + $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); + + $response = $vendingMachine->execute('Q, Q, Q, Q, GET-A'); + + self::assertEquals(35 ,$response->rest()->count()); + } } From 4a7b9f1b81c1d007c625b4c6cf6f32d48bab09b9 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Tue, 25 Jan 2022 19:42:21 +0100 Subject: [PATCH 65/87] feat: recognize product code from input, change values in items to consts --- composer.json | 1 + src/Command/BuyItemCommand.php | 6 ++--- src/Item/Item.php | 12 +++++----- src/Item/ItemA.php | 4 ++-- src/Item/ItemB.php | 4 ++-- src/Item/ItemC.php | 4 ++-- src/Repository/InMemoryItemRepository.php | 4 ++-- src/Repository/ItemRepository.php | 2 +- src/Request/BuyItemRequest.php | 23 ++----------------- src/Request/ConsoleRequest.php | 12 ++++++++++ src/Util/ConsoleInputParser.php | 12 +++++++--- src/Util/InputParser.php | 2 +- src/VendingMachine.php | 13 +++++++---- tests/Command/BuyItemCommandTest.php | 4 ++-- .../Repository/InMemoryItemRepositoryTest.php | 2 ++ tests/Util/InputParserTest.php | 7 ++++++ tests/VendingMachine/VendingMachineTest.php | 4 ++-- 17 files changed, 65 insertions(+), 51 deletions(-) diff --git a/composer.json b/composer.json index 18e3494..7450709 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ } ], "require": { + "php": "8.1" }, "require-dev": { "phpunit/phpunit": "^9", diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index d8b87e8..cd8740a 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -32,11 +32,11 @@ public function execute(BuyItemRequest $request): ConsoleResponse $item = $request->item(); $moneys = $request->moneyCollection(); - $availableItem = $this->itemRepository->getItemBySelector($item->selector()); + $availableItem = $this->itemRepository->getItemBySelector($item); - if (!$availableItem) throw new \InvalidArgumentException(sprintf('Item %s is not available', $item->selector())); + if (!$availableItem) throw new \InvalidArgumentException(sprintf('Item %s is not available', $item)); - if ($item->enoughToBuy($moneys->count())) { + if ($availableItem->enoughToBuy($moneys->count())) { return $this->response->setRest( $this->paymentCoordinator->pay($moneys->count(), $availableItem->value()) ); diff --git a/src/Item/Item.php b/src/Item/Item.php index fc9134b..63ebb39 100644 --- a/src/Item/Item.php +++ b/src/Item/Item.php @@ -6,27 +6,27 @@ abstract class Item { - protected string $selector = ''; + protected const SELECTOR = ''; - protected int $value = 0; + protected const VALUE = 0; public function value(): int { - return $this->value; + return static::VALUE; } public function selector(): string { - return $this->selector; + return static::SELECTOR; } public function equalsBySelector(string $selector): bool { - return $this->selector === $selector; + return static::SELECTOR === $selector; } public function enoughToBuy(int $count): bool { - return $count >= $this->value; + return $count >= static::VALUE; } } diff --git a/src/Item/ItemA.php b/src/Item/ItemA.php index fd528c5..9035c7d 100644 --- a/src/Item/ItemA.php +++ b/src/Item/ItemA.php @@ -6,7 +6,7 @@ final class ItemA extends Item { - protected string $selector = 'A'; + protected const SELECTOR = 'A'; - protected int $value = 65; + protected const VALUE = 65; } diff --git a/src/Item/ItemB.php b/src/Item/ItemB.php index 9c4677f..b7eca05 100644 --- a/src/Item/ItemB.php +++ b/src/Item/ItemB.php @@ -6,7 +6,7 @@ final class ItemB extends Item { - protected string $selector = 'B'; + protected const SELECTOR = 'B'; - protected int $value = 100; + protected const VALUE = 100; } diff --git a/src/Item/ItemC.php b/src/Item/ItemC.php index a4be052..1e2f937 100644 --- a/src/Item/ItemC.php +++ b/src/Item/ItemC.php @@ -6,7 +6,7 @@ final class ItemC extends Item { - protected string $selector = 'C'; + protected const SELECTOR = 'C'; - protected int $value = 150; + protected const VALUE = 150; } diff --git a/src/Repository/InMemoryItemRepository.php b/src/Repository/InMemoryItemRepository.php index f20f63f..7240db4 100644 --- a/src/Repository/InMemoryItemRepository.php +++ b/src/Repository/InMemoryItemRepository.php @@ -16,10 +16,10 @@ public function add(Item $item): void $this->items[] = $item; } - public function getItemBySelector($selector): ?Item + public function getItemBySelector(string $selector): ?Item { $filtered = array_filter($this->items, static function(Item $item) use ($selector) { - return $item->equalsBySelector($selector); + return $item->selector() === $selector; }); return count($filtered) ? reset($filtered) : null; diff --git a/src/Repository/ItemRepository.php b/src/Repository/ItemRepository.php index bb357ff..b4a6796 100644 --- a/src/Repository/ItemRepository.php +++ b/src/Repository/ItemRepository.php @@ -8,7 +8,7 @@ interface ItemRepository { public function add(Item $item): void; - public function getItemBySelector($selector): ?Item; + public function getItemBySelector(string $selector): ?Item; /** @return array|Item[] */ public function getAll(): array; diff --git a/src/Request/BuyItemRequest.php b/src/Request/BuyItemRequest.php index a916f82..5f571a0 100644 --- a/src/Request/BuyItemRequest.php +++ b/src/Request/BuyItemRequest.php @@ -4,39 +4,20 @@ namespace VendingMachine\Request; -use VendingMachine\Item\Item; use VendingMachine\Model\MoneyCollection; class BuyItemRequest { - /** - * @var Item - */ - private Item $item; - - /** - * @var MoneyCollection - */ - private MoneyCollection $moneyCollection; - - public function __construct(Item $item, MoneyCollection $moneyCollection) + public function __construct(private string $item, private MoneyCollection $moneyCollection) { - $this->item = $item; - $this->moneyCollection = $moneyCollection; } - /** - * @return MoneyCollection - */ public function moneyCollection(): MoneyCollection { return $this->moneyCollection; } - /** - * @return Item - */ - public function item(): Item + public function item(): string { return $this->item; } diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index 03524df..3f862af 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -16,6 +16,8 @@ class ConsoleRequest implements Request */ protected string $action; + protected string $productShortCode; + public function __construct(string $action) { $this->assertAction($action); @@ -64,4 +66,14 @@ public function moneyCollection(): MoneyCollection { return $this->moneys; } + + public function setProductShortCode(string $productShortCode): void + { + $this->productShortCode = $productShortCode; + } + + public function productShortCode(): string + { + return $this->productShortCode; + } } diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php index cddd5a3..93485a2 100644 --- a/src/Util/ConsoleInputParser.php +++ b/src/Util/ConsoleInputParser.php @@ -23,6 +23,8 @@ public function parse(string $input): ConsoleRequest // code smelling $consoleRequest->setMoney(new MoneyCollection($money)); + $consoleRequest->setProductShortCode($this->filterProductCode($action)); + return $consoleRequest; } @@ -46,9 +48,8 @@ private function filterAction(array $parameters): string } } - if ($action === null) { - throw new \LogicException(sprintf('No action found for %s', ...$parameters)); - } + if (!$action) throw new \LogicException(sprintf('No action found for %s', ...$parameters)); + return $action; } @@ -74,4 +75,9 @@ public function filterMoney(array $parameters): array return $money; } + private function filterProductCode(string $action): string + { + return explode('-', $action)[1]; + } + } diff --git a/src/Util/InputParser.php b/src/Util/InputParser.php index 550764b..9724741 100644 --- a/src/Util/InputParser.php +++ b/src/Util/InputParser.php @@ -1,9 +1,9 @@ parseInput($input); - $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); + if (preg_match('/GET-[A-C]/', $input)) { + $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); + // get item from input and parse it + return $buyCommand->execute( + new BuyItemRequest($request->productShortCode(), $request->moneyCollection()) + ); + } + + throw new \RuntimeException('Vending machine has error. Try again, please.'); - return $buyCommand->execute( - new BuyItemRequest(new ItemB(), $request->moneyCollection()) - ); } private function parseInput(string $input): ConsoleRequest diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php index 7ae9593..28d3a1c 100644 --- a/tests/Command/BuyItemCommandTest.php +++ b/tests/Command/BuyItemCommandTest.php @@ -24,7 +24,7 @@ public function testShouldReturnBoughtBItem(): void $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); $result = $buyItemCommand->execute( - new BuyItemRequest(new ItemB(), new MoneyCollection([new Dollar()])) + new BuyItemRequest('B', new MoneyCollection([new Dollar()])) ); self::assertInstanceOf(ConsoleResponse::class, $result); @@ -38,7 +38,7 @@ public function testShouldCalculateRestAndReturnResponseWithCorrectAmount(): voi $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); $result = $buyItemCommand->execute( - new BuyItemRequest(new ItemB(), new MoneyCollection([new Dollar()])) + new BuyItemRequest('B', new MoneyCollection([new Dollar()])) ); self::assertEquals(0, $result->rest()->count()); diff --git a/tests/Repository/InMemoryItemRepositoryTest.php b/tests/Repository/InMemoryItemRepositoryTest.php index bfe1804..7f13eef 100644 --- a/tests/Repository/InMemoryItemRepositoryTest.php +++ b/tests/Repository/InMemoryItemRepositoryTest.php @@ -27,6 +27,8 @@ public function testShouldReturnItemBySelector(): void $repository->add(new ItemB()); $repository->add(new ItemC()); + $itemBselector = (new ItemB())->selector(); + $result = $repository->getItemBySelector((new ItemB())->selector()); self::assertEquals(new ItemB(), $result); diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index 6ff29bd..da96003 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -34,6 +34,13 @@ public function testShouldParseInputAndReturnConsoleRequestWithActionGet(): void self::assertEquals('GET-B', $request->action()); } + public function testShouldReturnProductCodeFromInput(): void + { + $request = $this->parser->parse('Q, Q, Q, Q, GET-B'); + + self::assertEquals('B', $request->productShortCode()); + } + /** * @return void * @dataProvider dataSetForParsingMoney diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 19a6765..d0ead8f 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -35,11 +35,11 @@ public function testShouldThrowAnExceptionWhenNoActionFound(): void public function testShouldOrderProductAndSpendAllMoney(): void { $repository = new InMemoryItemRepository(); - $repository->add(new ItemC()); + $repository->add(new ItemB()); $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); - $response = $vendingMachine->execute('Q, Q, Q, Q, GET-C'); + $response = $vendingMachine->execute('Q, Q, Q, Q, GET-B'); self::assertEquals(0 ,$response->rest()->count()); } From 8627062734e665b8e4c5e383f730ffeb9a03ecfa Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Wed, 26 Jan 2022 19:58:10 +0100 Subject: [PATCH 66/87] ref: remove command factory --- src/Factory/CommandFactory.php | 16 ---------------- tests/Factory/CommandFactoryTest.php | 22 ---------------------- 2 files changed, 38 deletions(-) delete mode 100644 src/Factory/CommandFactory.php delete mode 100644 tests/Factory/CommandFactoryTest.php diff --git a/src/Factory/CommandFactory.php b/src/Factory/CommandFactory.php deleted file mode 100644 index f11375e..0000000 --- a/src/Factory/CommandFactory.php +++ /dev/null @@ -1,16 +0,0 @@ -markTestSkipped(); - - $commandFactory = new CommandFactory(); - $command = $commandFactory->create('Q, Q, Q, Q, GET-B'); - - self::assertInstanceOf(BuyItemCommand::class, $command); - } -} From a599630dcef89ea4f69ed28e7b5ec49f82f19e61 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Wed, 26 Jan 2022 20:03:49 +0100 Subject: [PATCH 67/87] test: formatting of exception, add test to expecting exception --- src/Command/BuyItemCommand.php | 4 +++- tests/VendingMachine/VendingMachineTest.php | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index cd8740a..d7de968 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -34,7 +34,9 @@ public function execute(BuyItemRequest $request): ConsoleResponse $availableItem = $this->itemRepository->getItemBySelector($item); - if (!$availableItem) throw new \InvalidArgumentException(sprintf('Item %s is not available', $item)); + if (!$availableItem) { + throw new \InvalidArgumentException(sprintf('Item %s is not available', $item)); + } if ($availableItem->enoughToBuy($moneys->count())) { return $this->response->setRest( diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index d0ead8f..948f8dc 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -41,7 +41,7 @@ public function testShouldOrderProductAndSpendAllMoney(): void $response = $vendingMachine->execute('Q, Q, Q, Q, GET-B'); - self::assertEquals(0 ,$response->rest()->count()); + self::assertEquals(0, $response->rest()->count()); } public function testShouldOrderProductAndGetRest(): void @@ -53,6 +53,19 @@ public function testShouldOrderProductAndGetRest(): void $response = $vendingMachine->execute('Q, Q, Q, Q, GET-A'); - self::assertEquals(35 ,$response->rest()->count()); + self::assertEquals(35, $response->rest()->count()); } + + public function testShouldThrowExceptionWhileOrderingProductIsNotAvailable(): void + { + $this->expectException(\InvalidArgumentException::class); + + $repository = new InMemoryItemRepository(); + $repository->add(new ItemA()); + + $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); + + $vendingMachine->execute('Q, Q, Q, Q, GET-B'); + } + } From 63ef9f1382462815aabcd476580d1b04755030b0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Wed, 26 Jan 2022 20:16:40 +0100 Subject: [PATCH 68/87] test: check returning output --- src/Command/BuyItemCommand.php | 2 ++ src/Response/ConsoleResponse.php | 20 +++++++++----------- tests/VendingMachine/VendingMachineTest.php | 9 ++++++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index d7de968..a1d4a95 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -39,6 +39,8 @@ public function execute(BuyItemRequest $request): ConsoleResponse } if ($availableItem->enoughToBuy($moneys->count())) { + $this->response->setProduct($availableItem); + return $this->response->setRest( $this->paymentCoordinator->pay($moneys->count(), $availableItem->value()) ); diff --git a/src/Response/ConsoleResponse.php b/src/Response/ConsoleResponse.php index 5fb6ba4..9ef989d 100644 --- a/src/Response/ConsoleResponse.php +++ b/src/Response/ConsoleResponse.php @@ -4,35 +4,33 @@ namespace VendingMachine\Response; +use VendingMachine\Item\Item; use VendingMachine\Model\MoneyCollection; class ConsoleResponse { - /** - * @var MoneyCollection - */ + private Item $product; + private MoneyCollection $rest; - /** - * @param MoneyCollection $rest - * @return ConsoleResponse - */ public function setRest(MoneyCollection $rest): ConsoleResponse { $this->rest = $rest; return $this; } - /** - * @return MoneyCollection - */ public function rest(): MoneyCollection { return $this->rest; } + public function setProduct(Item $product): void + { + $this->product = $product; + } + public function getOutput(): string { - return "resztaaa! \n"; + return $this->product->selector(); } } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 948f8dc..e33c5d6 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; use VendingMachine\Item\ItemA; use VendingMachine\Item\ItemB; -use VendingMachine\Item\ItemC; +use VendingMachine\Model\Dime; +use VendingMachine\Model\Quarter; use VendingMachine\Repository\InMemoryItemRepository; use VendingMachine\Repository\ItemRepository; use VendingMachine\Util\ConsoleInputParser; @@ -42,6 +43,7 @@ public function testShouldOrderProductAndSpendAllMoney(): void $response = $vendingMachine->execute('Q, Q, Q, Q, GET-B'); self::assertEquals(0, $response->rest()->count()); + self::assertEquals('B', $response->getOutput()); } public function testShouldOrderProductAndGetRest(): void @@ -54,6 +56,11 @@ public function testShouldOrderProductAndGetRest(): void $response = $vendingMachine->execute('Q, Q, Q, Q, GET-A'); self::assertEquals(35, $response->rest()->count()); + self::assertEquals([ + new Quarter(), + new Dime(), + ], $response->rest()->money()); + self::assertEquals('A', $response->getOutput()); } public function testShouldThrowExceptionWhileOrderingProductIsNotAvailable(): void From d9347a1170659c660da581741ee26df939063fd0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 16:28:27 +0100 Subject: [PATCH 69/87] test: order with dollar without exact change, and get rest --- src/Model/Dollar.php | 2 +- src/Util/ConsoleInputParser.php | 10 +++++----- tests/VendingMachine/VendingMachineTest.php | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Model/Dollar.php b/src/Model/Dollar.php index b795bd5..08fa0ab 100644 --- a/src/Model/Dollar.php +++ b/src/Model/Dollar.php @@ -6,7 +6,7 @@ final class Dollar extends Money implements PaperMoney { - protected string $shortCode = 'Dollar'; + protected string $shortCode = 'DOLLAR'; protected int $value = 100; } diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php index 93485a2..f315e57 100644 --- a/src/Util/ConsoleInputParser.php +++ b/src/Util/ConsoleInputParser.php @@ -32,7 +32,7 @@ private function splitParameters(string $input): array { $request = explode(',', $input); - return array_map(static function($element) { + return array_map(static function ($element) { return trim($element); }, $request); } @@ -48,7 +48,9 @@ private function filterAction(array $parameters): string } } - if (!$action) throw new \LogicException(sprintf('No action found for %s', ...$parameters)); + if (!$action) { + throw new \LogicException(sprintf('No action found for %s', ...$parameters)); + } return $action; } @@ -58,14 +60,13 @@ public function filterMoney(array $parameters): array $money = []; /** @var string $parameter */ foreach ($parameters as $parameter) { - $results = array_filter(AvailableMoney::getMoney(), static function(Money $money) use ($parameter) { + $results = array_filter(AvailableMoney::getMoney(), static function (Money $money) use ($parameter) { return $money->shortCode() === $parameter; }); if (count($results) === 1) { $money[] = reset($results); } - } if (empty($money)) { @@ -79,5 +80,4 @@ private function filterProductCode(string $action): string { return explode('-', $action)[1]; } - } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index e33c5d6..861ebf8 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -75,4 +75,21 @@ public function testShouldThrowExceptionWhileOrderingProductIsNotAvailable(): vo $vendingMachine->execute('Q, Q, Q, Q, GET-B'); } + public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void + { + $repository = new InMemoryItemRepository(); + $repository->add(new ItemA()); + + $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); + + $response = $vendingMachine->execute('DOLLAR, GET-A'); + + self::assertEquals(35, $response->rest()->count()); + self::assertEquals([ + new Quarter(), + new Dime(), + ], $response->rest()->money()); + self::assertEquals('A', $response->getOutput()); + } + } From 181dd66d1760f8c62a325401111a16693e6f21c0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 16:33:52 +0100 Subject: [PATCH 70/87] ref: extract buy command --- src/VendingMachine.php | 22 ++++++++++++++------- tests/VendingMachine/VendingMachineTest.php | 10 ++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/VendingMachine.php b/src/VendingMachine.php index bfabe57..94fae55 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -30,19 +30,27 @@ public function execute(string $input): ConsoleResponse $request = $this->parseInput($input); if (preg_match('/GET-[A-C]/', $input)) { - $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); - // get item from input and parse it - return $buyCommand->execute( - new BuyItemRequest($request->productShortCode(), $request->moneyCollection()) - ); + return $this->executeBuy($request); } - throw new \RuntimeException('Vending machine has error. Try again, please.'); - } private function parseInput(string $input): ConsoleRequest { return $this->inputParser->parse($input); } + + /** + * @param ConsoleRequest $request + * @return ConsoleResponse + */ + private function executeBuy(ConsoleRequest $request): ConsoleResponse + { + $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); + // get item from input and parse it + return $buyCommand->execute( + new BuyItemRequest($request->productShortCode(), $request->moneyCollection()) + ); + } + } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 861ebf8..76a0dbe 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -92,4 +92,14 @@ public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void self::assertEquals('A', $response->getOutput()); } +// public function testShouldReturnInsertedCoinsOnCoinReturn(): void +// { +// $repository = new InMemoryItemRepository(); +// $repository->add(new ItemA()); +// +// $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); +// +// $response = $vendingMachine->execute('DOLLAR, GET-A'); +// } + } From 03a68b903904624fee95f411ec2a212f93d04556 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 17:13:30 +0100 Subject: [PATCH 71/87] feat: implement interfaces and CoinReturnCommand tests --- src/Command/CoinReturnCommand.php | 14 ++++++++++++++ src/Command/Command.php | 5 +++-- src/Request/BuyItemRequest.php | 2 +- src/Request/CoinReturnRequest.php | 17 +++++++++++++++++ src/Request/CommandRequest.php | 8 ++++++++ src/Request/ConsoleRequest.php | 14 +------------- src/Response/ConsoleResponse.php | 2 +- src/Response/Response.php | 8 ++++++++ src/VendingMachine.php | 2 ++ tests/Command/CoinReturnCommandTest.php | 24 ++++++++++++++++++++++++ 10 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 src/Command/CoinReturnCommand.php create mode 100644 src/Request/CoinReturnRequest.php create mode 100644 src/Request/CommandRequest.php create mode 100644 src/Response/Response.php create mode 100644 tests/Command/CoinReturnCommandTest.php diff --git a/src/Command/CoinReturnCommand.php b/src/Command/CoinReturnCommand.php new file mode 100644 index 0000000..8fc59b3 --- /dev/null +++ b/src/Command/CoinReturnCommand.php @@ -0,0 +1,14 @@ +setRest($request->moneyCollection()); + } +} \ No newline at end of file diff --git a/src/Command/Command.php b/src/Command/Command.php index 505a19d..c4f9612 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -4,9 +4,10 @@ namespace VendingMachine\Command; -use VendingMachine\Request\Request; +use VendingMachine\Request\CommandRequest; +use VendingMachine\Response\Response; interface Command { - public function execute(Request $request); + public function execute(CommandRequest $request): Response; } diff --git a/src/Request/BuyItemRequest.php b/src/Request/BuyItemRequest.php index 5f571a0..ce670cd 100644 --- a/src/Request/BuyItemRequest.php +++ b/src/Request/BuyItemRequest.php @@ -6,7 +6,7 @@ use VendingMachine\Model\MoneyCollection; -class BuyItemRequest +class BuyItemRequest implements CommandRequest { public function __construct(private string $item, private MoneyCollection $moneyCollection) { diff --git a/src/Request/CoinReturnRequest.php b/src/Request/CoinReturnRequest.php new file mode 100644 index 0000000..0be594c --- /dev/null +++ b/src/Request/CoinReturnRequest.php @@ -0,0 +1,17 @@ +moneyCollection; + } +} \ No newline at end of file diff --git a/src/Request/CommandRequest.php b/src/Request/CommandRequest.php new file mode 100644 index 0000000..c6c7092 --- /dev/null +++ b/src/Request/CommandRequest.php @@ -0,0 +1,8 @@ +moneys = new MoneyCollection([]); } - /** - * @param Money $money - */ public function addMoney(Money $money): void { $this->moneys->addMoney($money); } - /** - * @param MoneyCollection $moneys - */ public function setMoney(MoneyCollection $moneys): void { $this->moneys = $moneys; } - /** - * @param string $action - */ public function assertAction(string $action): void { if (!preg_match('/GET-[A-C]/', $action)) { @@ -52,7 +40,7 @@ public function assertAction(string $action): void } } - public function action(): string + public function action(): string { return $this->action; } diff --git a/src/Response/ConsoleResponse.php b/src/Response/ConsoleResponse.php index 9ef989d..47db3cc 100644 --- a/src/Response/ConsoleResponse.php +++ b/src/Response/ConsoleResponse.php @@ -7,7 +7,7 @@ use VendingMachine\Item\Item; use VendingMachine\Model\MoneyCollection; -class ConsoleResponse +class ConsoleResponse implements Response { private Item $product; diff --git a/src/Response/Response.php b/src/Response/Response.php new file mode 100644 index 0000000..df15a46 --- /dev/null +++ b/src/Response/Response.php @@ -0,0 +1,8 @@ +parseInput($input); + // match expression ? if (preg_match('/GET-[A-C]/', $input)) { return $this->executeBuy($request); } + throw new \RuntimeException('Vending machine has error. Try again, please.'); } diff --git a/tests/Command/CoinReturnCommandTest.php b/tests/Command/CoinReturnCommandTest.php new file mode 100644 index 0000000..27cad02 --- /dev/null +++ b/tests/Command/CoinReturnCommandTest.php @@ -0,0 +1,24 @@ +execute(new CoinReturnRequest($moneyCollection)); + + self::assertEquals(new MoneyCollection([new Dime(), new Dollar()]), $result->rest()); + } +} \ No newline at end of file From 13f824cf788e3b4b5a9eba99af61b9307cf99142 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 17:41:47 +0100 Subject: [PATCH 72/87] feat: first implementation of return coins command --- src/Command/CoinReturnCommand.php | 7 ++++--- src/Request/ConsoleRequest.php | 4 ++-- src/Util/ConsoleInputParser.php | 9 +++++++++ src/VendingMachine.php | 21 +++++++++++++++------ tests/Command/CoinReturnCommandTest.php | 2 +- tests/Util/InputParserTest.php | 7 +++++++ tests/VendingMachine/VendingMachineTest.php | 17 ++++++++--------- 7 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/Command/CoinReturnCommand.php b/src/Command/CoinReturnCommand.php index 8fc59b3..e99521d 100644 --- a/src/Command/CoinReturnCommand.php +++ b/src/Command/CoinReturnCommand.php @@ -3,12 +3,13 @@ namespace VendingMachine\Command; use VendingMachine\Request\CoinReturnRequest; -use VendingMachine\Response\ConsoleResponse; +use VendingMachine\Response\CoinReturnConsoleResponse; +use VendingMachine\Response\Response; class CoinReturnCommand { - public function execute(CoinReturnRequest $request): ConsoleResponse + public function execute(CoinReturnRequest $request): Response { - return (new ConsoleResponse)->setRest($request->moneyCollection()); + return (new CoinReturnConsoleResponse($request->moneyCollection())); } } \ No newline at end of file diff --git a/src/Request/ConsoleRequest.php b/src/Request/ConsoleRequest.php index 1ec8ac1..dbc78b8 100644 --- a/src/Request/ConsoleRequest.php +++ b/src/Request/ConsoleRequest.php @@ -35,8 +35,8 @@ public function setMoney(MoneyCollection $moneys): void public function assertAction(string $action): void { - if (!preg_match('/GET-[A-C]/', $action)) { - throw new \InvalidArgumentException('Invalid action name!'); + if ($action !== 'COIN-RETURN' && !preg_match('/GET-[A-C]/', $action)) { + throw new \InvalidArgumentException(sprintf('Invalid action name %s!', $action)); } } diff --git a/src/Util/ConsoleInputParser.php b/src/Util/ConsoleInputParser.php index f315e57..f8ddc36 100644 --- a/src/Util/ConsoleInputParser.php +++ b/src/Util/ConsoleInputParser.php @@ -40,6 +40,7 @@ private function splitParameters(string $input): array private function filterAction(array $parameters): string { $action = null; + // array_filter /** @var string $parameter */ foreach ($parameters as $parameter) { // filter action - set to ConsoleRequest @@ -48,6 +49,14 @@ private function filterAction(array $parameters): string } } + // array_filter + foreach ($parameters as $parameter) { + // filter action - set to ConsoleRequest + if (str_contains($parameter, 'COIN-RETURN')) { + $action = $parameter; + } + } + if (!$action) { throw new \LogicException(sprintf('No action found for %s', ...$parameters)); } diff --git a/src/VendingMachine.php b/src/VendingMachine.php index d18eb8d..2b35513 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -5,12 +5,15 @@ namespace VendingMachine; use VendingMachine\Command\BuyItemCommand; +use VendingMachine\Command\CoinReturnCommand; use VendingMachine\Coordinator\PaymentCoordinator; use VendingMachine\Item\ItemB; use VendingMachine\Repository\ItemRepository; use VendingMachine\Request\BuyItemRequest; +use VendingMachine\Request\CoinReturnRequest; use VendingMachine\Request\ConsoleRequest; use VendingMachine\Response\ConsoleResponse; +use VendingMachine\Response\Response; use VendingMachine\Util\InputParser; final class VendingMachine @@ -25,7 +28,7 @@ public function __construct(ItemRepository $itemRepository, InputParser $inputPa $this->inputParser = $inputParser; } - public function execute(string $input): ConsoleResponse + public function execute(string $input): Response { $request = $this->parseInput($input); @@ -34,6 +37,10 @@ public function execute(string $input): ConsoleResponse return $this->executeBuy($request); } + if (str_contains($input, 'COIN-RETURN')) { + return $this->executeCoinReturn($request); + } + throw new \RuntimeException('Vending machine has error. Try again, please.'); } @@ -42,11 +49,7 @@ private function parseInput(string $input): ConsoleRequest return $this->inputParser->parse($input); } - /** - * @param ConsoleRequest $request - * @return ConsoleResponse - */ - private function executeBuy(ConsoleRequest $request): ConsoleResponse + private function executeBuy(ConsoleRequest $request): Response { $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); // get item from input and parse it @@ -55,4 +58,10 @@ private function executeBuy(ConsoleRequest $request): ConsoleResponse ); } + private function executeCoinReturn(ConsoleRequest $request): Response + { + return (new CoinReturnCommand())->execute( + new CoinReturnRequest($request->moneyCollection()) + ); + } } diff --git a/tests/Command/CoinReturnCommandTest.php b/tests/Command/CoinReturnCommandTest.php index 27cad02..adc6585 100644 --- a/tests/Command/CoinReturnCommandTest.php +++ b/tests/Command/CoinReturnCommandTest.php @@ -19,6 +19,6 @@ public function testShouldReturnInsertedCoinsInRest(): void $result = $command->execute(new CoinReturnRequest($moneyCollection)); - self::assertEquals(new MoneyCollection([new Dime(), new Dollar()]), $result->rest()); + self::assertEquals('D, DOLLAR', $result->getOutput()); } } \ No newline at end of file diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index da96003..16fe5fe 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -41,6 +41,13 @@ public function testShouldReturnProductCodeFromInput(): void self::assertEquals('B', $request->productShortCode()); } + public function testShouldRecognizeCoinReturnAction(): void + { + $request = $this->parser->parse('Q, Q, Q, Q, COIN-RETURN'); + + self::assertEquals('COIN-RETURN', $request->action()); + } + /** * @return void * @dataProvider dataSetForParsingMoney diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 76a0dbe..f96c692 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -92,14 +92,13 @@ public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void self::assertEquals('A', $response->getOutput()); } -// public function testShouldReturnInsertedCoinsOnCoinReturn(): void -// { -// $repository = new InMemoryItemRepository(); -// $repository->add(new ItemA()); -// -// $vendingMachine = new VendingMachine($repository, new ConsoleInputParser()); -// -// $response = $vendingMachine->execute('DOLLAR, GET-A'); -// } + public function testShouldReturnInsertedCoinsOnCoinReturn(): void + { + $vendingMachine = new VendingMachine(new InMemoryItemRepository(), new ConsoleInputParser()); + + $response = $vendingMachine->execute('Q, Q, COIN-RETURN'); + + self::assertEquals('Q, Q', $response->getOutput()); + } } From 246b94912f012c353bbf791220836baffb16a007 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 19:02:18 +0100 Subject: [PATCH 73/87] feat: coin return response --- src/Response/CoinReturnConsoleResponse.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/Response/CoinReturnConsoleResponse.php diff --git a/src/Response/CoinReturnConsoleResponse.php b/src/Response/CoinReturnConsoleResponse.php new file mode 100644 index 0000000..98ac8d0 --- /dev/null +++ b/src/Response/CoinReturnConsoleResponse.php @@ -0,0 +1,21 @@ + $money->shortCode(), $this->moneyCollection->money()) + ); + } +} \ No newline at end of file From 93cc8e2e3f9ccfba3a6d61728259e195ccd940a0 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 19:07:56 +0100 Subject: [PATCH 74/87] feat: return rest with ordered product --- src/Model/MoneyCollection.php | 5 +++++ src/Response/ConsoleResponse.php | 2 +- tests/VendingMachine/VendingMachineTest.php | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Model/MoneyCollection.php b/src/Model/MoneyCollection.php index ffa6fee..7bdd227 100644 --- a/src/Model/MoneyCollection.php +++ b/src/Model/MoneyCollection.php @@ -36,4 +36,9 @@ public function count(): int return $sum; } + + public function toArray(): array + { + return array_map(static fn(Money $money) => $money->shortCode(), $this->money()); + } } diff --git a/src/Response/ConsoleResponse.php b/src/Response/ConsoleResponse.php index 47db3cc..4b84621 100644 --- a/src/Response/ConsoleResponse.php +++ b/src/Response/ConsoleResponse.php @@ -31,6 +31,6 @@ public function setProduct(Item $product): void public function getOutput(): string { - return $this->product->selector(); + return implode(', ', array: [$this->product->selector(), ...$this->rest->toArray()]); } } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index f96c692..d9bbaa9 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -60,7 +60,7 @@ public function testShouldOrderProductAndGetRest(): void new Quarter(), new Dime(), ], $response->rest()->money()); - self::assertEquals('A', $response->getOutput()); + self::assertEquals('A, Q, D', $response->getOutput()); } public function testShouldThrowExceptionWhileOrderingProductIsNotAvailable(): void @@ -89,7 +89,7 @@ public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void new Quarter(), new Dime(), ], $response->rest()->money()); - self::assertEquals('A', $response->getOutput()); + self::assertEquals('A, Q, D', $response->getOutput()); } public function testShouldReturnInsertedCoinsOnCoinReturn(): void From b3ac1f1897a9c35462076c635b7bd82f065d7791 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 19:10:28 +0100 Subject: [PATCH 75/87] ref: change name to result --- src/Response/CoinReturnConsoleResponse.php | 2 +- src/Response/ConsoleResponse.php | 2 +- src/Response/Response.php | 2 +- tests/Command/CoinReturnCommandTest.php | 2 +- tests/VendingMachine/VendingMachineTest.php | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Response/CoinReturnConsoleResponse.php b/src/Response/CoinReturnConsoleResponse.php index 98ac8d0..e32c042 100644 --- a/src/Response/CoinReturnConsoleResponse.php +++ b/src/Response/CoinReturnConsoleResponse.php @@ -11,7 +11,7 @@ public function __construct(private MoneyCollection $moneyCollection) { } - public function getOutput(): string + public function result(): string { return implode( ', ', diff --git a/src/Response/ConsoleResponse.php b/src/Response/ConsoleResponse.php index 4b84621..ad7f561 100644 --- a/src/Response/ConsoleResponse.php +++ b/src/Response/ConsoleResponse.php @@ -29,7 +29,7 @@ public function setProduct(Item $product): void $this->product = $product; } - public function getOutput(): string + public function result(): string { return implode(', ', array: [$this->product->selector(), ...$this->rest->toArray()]); } diff --git a/src/Response/Response.php b/src/Response/Response.php index df15a46..9bb8815 100644 --- a/src/Response/Response.php +++ b/src/Response/Response.php @@ -4,5 +4,5 @@ interface Response { - public function getOutput(): string; + public function result(): string; } diff --git a/tests/Command/CoinReturnCommandTest.php b/tests/Command/CoinReturnCommandTest.php index adc6585..d458ac7 100644 --- a/tests/Command/CoinReturnCommandTest.php +++ b/tests/Command/CoinReturnCommandTest.php @@ -19,6 +19,6 @@ public function testShouldReturnInsertedCoinsInRest(): void $result = $command->execute(new CoinReturnRequest($moneyCollection)); - self::assertEquals('D, DOLLAR', $result->getOutput()); + self::assertEquals('D, DOLLAR', $result->result()); } } \ No newline at end of file diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index d9bbaa9..029f5a1 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -43,7 +43,7 @@ public function testShouldOrderProductAndSpendAllMoney(): void $response = $vendingMachine->execute('Q, Q, Q, Q, GET-B'); self::assertEquals(0, $response->rest()->count()); - self::assertEquals('B', $response->getOutput()); + self::assertEquals('B', $response->result()); } public function testShouldOrderProductAndGetRest(): void @@ -60,7 +60,7 @@ public function testShouldOrderProductAndGetRest(): void new Quarter(), new Dime(), ], $response->rest()->money()); - self::assertEquals('A, Q, D', $response->getOutput()); + self::assertEquals('A, Q, D', $response->result()); } public function testShouldThrowExceptionWhileOrderingProductIsNotAvailable(): void @@ -89,7 +89,7 @@ public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void new Quarter(), new Dime(), ], $response->rest()->money()); - self::assertEquals('A, Q, D', $response->getOutput()); + self::assertEquals('A, Q, D', $response->result()); } public function testShouldReturnInsertedCoinsOnCoinReturn(): void @@ -98,7 +98,7 @@ public function testShouldReturnInsertedCoinsOnCoinReturn(): void $response = $vendingMachine->execute('Q, Q, COIN-RETURN'); - self::assertEquals('Q, Q', $response->getOutput()); + self::assertEquals('Q, Q', $response->result()); } } From cba537d7db49e9db5b9c149ef249f1b7c3acb9a4 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 20:47:14 +0100 Subject: [PATCH 76/87] ref: implement Stringable interface --- src/Response/CoinReturnConsoleResponse.php | 9 +++++++-- src/Response/ConsoleResponse.php | 12 ++++++++++-- src/Response/Response.php | 4 ++-- tests/Command/CoinReturnCommandTest.php | 2 +- tests/VendingMachine/VendingMachineTest.php | 8 ++++---- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/Response/CoinReturnConsoleResponse.php b/src/Response/CoinReturnConsoleResponse.php index e32c042..165dd67 100644 --- a/src/Response/CoinReturnConsoleResponse.php +++ b/src/Response/CoinReturnConsoleResponse.php @@ -5,13 +5,18 @@ use VendingMachine\Model\Money; use VendingMachine\Model\MoneyCollection; -class CoinReturnConsoleResponse implements Response +class CoinReturnConsoleResponse extends Response { public function __construct(private MoneyCollection $moneyCollection) { } - public function result(): string + public function result(): MoneyCollection + { + return $this->moneyCollection; + } + + public function __toString() { return implode( ', ', diff --git a/src/Response/ConsoleResponse.php b/src/Response/ConsoleResponse.php index ad7f561..1bca8ae 100644 --- a/src/Response/ConsoleResponse.php +++ b/src/Response/ConsoleResponse.php @@ -7,7 +7,7 @@ use VendingMachine\Item\Item; use VendingMachine\Model\MoneyCollection; -class ConsoleResponse implements Response +class ConsoleResponse extends Response { private Item $product; @@ -29,7 +29,15 @@ public function setProduct(Item $product): void $this->product = $product; } - public function result(): string + public function result(): array + { + return [ + "product" => $this->product, + "rest" => $this->rest + ]; + } + + public function __toString(): string { return implode(', ', array: [$this->product->selector(), ...$this->rest->toArray()]); } diff --git a/src/Response/Response.php b/src/Response/Response.php index 9bb8815..1fbdd0a 100644 --- a/src/Response/Response.php +++ b/src/Response/Response.php @@ -2,7 +2,7 @@ namespace VendingMachine\Response; -interface Response +abstract class Response implements \Stringable { - public function result(): string; + abstract public function result(): mixed; } diff --git a/tests/Command/CoinReturnCommandTest.php b/tests/Command/CoinReturnCommandTest.php index d458ac7..4fedc96 100644 --- a/tests/Command/CoinReturnCommandTest.php +++ b/tests/Command/CoinReturnCommandTest.php @@ -19,6 +19,6 @@ public function testShouldReturnInsertedCoinsInRest(): void $result = $command->execute(new CoinReturnRequest($moneyCollection)); - self::assertEquals('D, DOLLAR', $result->result()); + self::assertEquals('D, DOLLAR', $result); } } \ No newline at end of file diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 029f5a1..2af321a 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -43,7 +43,7 @@ public function testShouldOrderProductAndSpendAllMoney(): void $response = $vendingMachine->execute('Q, Q, Q, Q, GET-B'); self::assertEquals(0, $response->rest()->count()); - self::assertEquals('B', $response->result()); + self::assertEquals('B', $response); } public function testShouldOrderProductAndGetRest(): void @@ -60,7 +60,7 @@ public function testShouldOrderProductAndGetRest(): void new Quarter(), new Dime(), ], $response->rest()->money()); - self::assertEquals('A, Q, D', $response->result()); + self::assertEquals('A, Q, D', $response); } public function testShouldThrowExceptionWhileOrderingProductIsNotAvailable(): void @@ -89,7 +89,7 @@ public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void new Quarter(), new Dime(), ], $response->rest()->money()); - self::assertEquals('A, Q, D', $response->result()); + self::assertEquals('A, Q, D', $response); } public function testShouldReturnInsertedCoinsOnCoinReturn(): void @@ -98,7 +98,7 @@ public function testShouldReturnInsertedCoinsOnCoinReturn(): void $response = $vendingMachine->execute('Q, Q, COIN-RETURN'); - self::assertEquals('Q, Q', $response->result()); + self::assertEquals('Q, Q', $response); } } From 19e7e640a7176541fd12df84c2cb801a9faf33f9 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 21:01:34 +0100 Subject: [PATCH 77/87] ref: set items shortcodes to regex --- src/Item/ItemsInSale.php | 5 +++++ src/VendingMachine.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Item/ItemsInSale.php b/src/Item/ItemsInSale.php index d52a9cb..24a5a50 100644 --- a/src/Item/ItemsInSale.php +++ b/src/Item/ItemsInSale.php @@ -14,4 +14,9 @@ public static function getItems(): array new ItemC() ]; } + + public static function itemShortCodes(): array + { + return array_map(static fn(Item $money) => $money->selector(), self::getItems()); + } } diff --git a/src/VendingMachine.php b/src/VendingMachine.php index 2b35513..c8346a0 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -8,6 +8,7 @@ use VendingMachine\Command\CoinReturnCommand; use VendingMachine\Coordinator\PaymentCoordinator; use VendingMachine\Item\ItemB; +use VendingMachine\Item\ItemsInSale; use VendingMachine\Repository\ItemRepository; use VendingMachine\Request\BuyItemRequest; use VendingMachine\Request\CoinReturnRequest; @@ -32,8 +33,7 @@ public function execute(string $input): Response { $request = $this->parseInput($input); - // match expression ? - if (preg_match('/GET-[A-C]/', $input)) { + if (preg_match("/GET-[" . implode('|', ItemsInSale::itemShortCodes()). "]/", $input)) { return $this->executeBuy($request); } From 8760377428dd650e4ea7265d71c0f73df641d72f Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 21:09:34 +0100 Subject: [PATCH 78/87] ref: move method with available coins to specialized class --- src/Coordinator/PaymentCoordinator.php | 20 ++++---------------- src/Model/AvailableMoney.php | 12 ++++++++++++ src/VendingMachine.php | 2 +- tests/Util/InputParserTest.php | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php index 17db433..72f17e2 100644 --- a/src/Coordinator/PaymentCoordinator.php +++ b/src/Coordinator/PaymentCoordinator.php @@ -5,7 +5,6 @@ namespace VendingMachine\Coordinator; use VendingMachine\Model\AvailableMoney; -use VendingMachine\Model\Coin; use VendingMachine\Model\Money; use VendingMachine\Model\MoneyCollection; @@ -15,10 +14,11 @@ public function pay(int $input, int $cost): MoneyCollection { if ($input >= $cost) { $rest = $input - $cost; - $coinRest = $this->calculateRest($rest, $this->getCoins()); - return new MoneyCollection($coinRest); + + return new MoneyCollection( + $this->calculateRest($rest, AvailableMoney::getCoins()) + ); } - // add domain exception with information about passed values throw new \InvalidArgumentException('No enough money to pay for it!'); } @@ -45,16 +45,4 @@ private function calculateRest(int $rest, array $coins): array return $coinRest; } - - private function getCoins(): array - { - $coins = AvailableMoney::coins(); - - // sort DESC - usort($coins, static function (Money $a, Money $b) { - return ($a->value() > $b->value()) ? -1 : 1; - }); - - return $coins; - } } diff --git a/src/Model/AvailableMoney.php b/src/Model/AvailableMoney.php index da234ae..d994a1c 100644 --- a/src/Model/AvailableMoney.php +++ b/src/Model/AvailableMoney.php @@ -24,4 +24,16 @@ public static function coins() new Quarter(), ]; } + + public static function getCoins(): array + { + $coins = self::coins(); + + // sort DESC + usort($coins, static function (Money $a, Money $b) { + return ($a->value() > $b->value()) ? -1 : 1; + }); + + return $coins; + } } diff --git a/src/VendingMachine.php b/src/VendingMachine.php index c8346a0..c685e33 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -7,7 +7,6 @@ use VendingMachine\Command\BuyItemCommand; use VendingMachine\Command\CoinReturnCommand; use VendingMachine\Coordinator\PaymentCoordinator; -use VendingMachine\Item\ItemB; use VendingMachine\Item\ItemsInSale; use VendingMachine\Repository\ItemRepository; use VendingMachine\Request\BuyItemRequest; @@ -33,6 +32,7 @@ public function execute(string $input): Response { $request = $this->parseInput($input); + if (preg_match("/GET-[" . implode('|', ItemsInSale::itemShortCodes()). "]/", $input)) { return $this->executeBuy($request); } diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index 16fe5fe..3f6ee00 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -5,7 +5,6 @@ namespace Tests\Util; use PHPUnit\Framework\TestCase; -use VendingMachine\Model\Dollar; use VendingMachine\Model\Nickel; use VendingMachine\Model\Quarter; use VendingMachine\Request\ConsoleRequest; @@ -49,6 +48,8 @@ public function testShouldRecognizeCoinReturnAction(): void } /** + * @param string $input + * @param array $output * @return void * @dataProvider dataSetForParsingMoney */ @@ -80,7 +81,6 @@ public function dataSetForParsingMoney(): array 'input' => 'N, GET-B', 'output' => [new Nickel()] ] - ]; } } From 10c5484124ffcf9f0abaddc984b9dabc4a53a41c Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 21:10:49 +0100 Subject: [PATCH 79/87] ref: php 8 arguments --- src/Command/BuyItemCommand.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index a1d4a95..faa196b 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -11,20 +11,11 @@ class BuyItemCommand { - private ItemRepository $itemRepository; - - private PaymentCoordinator $paymentCoordinator; - - private ConsoleResponse $response; - public function __construct( - ItemRepository $itemRepository, - PaymentCoordinator $paymentCoordinator, - ConsoleResponse $response + private ItemRepository $itemRepository, + private PaymentCoordinator $paymentCoordinator, + private ConsoleResponse $response ) { - $this->itemRepository = $itemRepository; - $this->paymentCoordinator = $paymentCoordinator; - $this->response = $response; } public function execute(BuyItemRequest $request): ConsoleResponse From 3a7e692817df776e0542d290d531a34a461c0a73 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 21:17:44 +0100 Subject: [PATCH 80/87] tests: add A item --- src/prompt.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/prompt.php b/src/prompt.php index 2a486f1..7e49aa0 100644 --- a/src/prompt.php +++ b/src/prompt.php @@ -4,6 +4,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; +use VendingMachine\Item\ItemA; use VendingMachine\Item\ItemB; use VendingMachine\Repository\InMemoryItemRepository; use VendingMachine\Util\ConsoleInputParser; @@ -11,6 +12,7 @@ $itemRepository = new InMemoryItemRepository(); $itemRepository->add(new ItemB()); +$itemRepository->add(new ItemA()); $vm = new VendingMachine($itemRepository, new ConsoleInputParser()); From fdfc0a3b6fb4abe73af08c0cbacf14e297a0ce85 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sat, 29 Jan 2022 21:19:37 +0100 Subject: [PATCH 81/87] ref: PSR-12 changes --- src/Command/BuyItemCommand.php | 2 +- src/Command/CoinReturnCommand.php | 2 +- src/Command/Command.php | 13 ------------- src/Repository/ItemRepository.php | 2 ++ src/Request/CoinReturnRequest.php | 4 +++- src/Request/CommandRequest.php | 2 ++ src/Response/CoinReturnConsoleResponse.php | 4 +++- src/Response/Response.php | 4 +++- 8 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 src/Command/Command.php diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index faa196b..a0bbec8 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -18,7 +18,7 @@ public function __construct( ) { } - public function execute(BuyItemRequest $request): ConsoleResponse + public function __invoke(BuyItemRequest $request): ConsoleResponse { $item = $request->item(); $moneys = $request->moneyCollection(); diff --git a/src/Command/CoinReturnCommand.php b/src/Command/CoinReturnCommand.php index e99521d..0f36c67 100644 --- a/src/Command/CoinReturnCommand.php +++ b/src/Command/CoinReturnCommand.php @@ -8,7 +8,7 @@ class CoinReturnCommand { - public function execute(CoinReturnRequest $request): Response + public function __invoke(CoinReturnRequest $request): Response { return (new CoinReturnConsoleResponse($request->moneyCollection())); } diff --git a/src/Command/Command.php b/src/Command/Command.php deleted file mode 100644 index c4f9612..0000000 --- a/src/Command/Command.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Sat, 29 Jan 2022 21:21:24 +0100 Subject: [PATCH 82/87] ref: replace to invokable, contravariance complicated class inheritance --- src/VendingMachine.php | 4 ++-- tests/Command/BuyItemCommandTest.php | 4 ++-- tests/Command/CoinReturnCommandTest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/VendingMachine.php b/src/VendingMachine.php index c685e33..f2af319 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -53,14 +53,14 @@ private function executeBuy(ConsoleRequest $request): Response { $buyCommand = new BuyItemCommand($this->itemRepository, new PaymentCoordinator(), new ConsoleResponse()); // get item from input and parse it - return $buyCommand->execute( + return $buyCommand( new BuyItemRequest($request->productShortCode(), $request->moneyCollection()) ); } private function executeCoinReturn(ConsoleRequest $request): Response { - return (new CoinReturnCommand())->execute( + return (new CoinReturnCommand())( new CoinReturnRequest($request->moneyCollection()) ); } diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php index 28d3a1c..3e56f65 100644 --- a/tests/Command/BuyItemCommandTest.php +++ b/tests/Command/BuyItemCommandTest.php @@ -23,7 +23,7 @@ public function testShouldReturnBoughtBItem(): void $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); - $result = $buyItemCommand->execute( + $result = $buyItemCommand( new BuyItemRequest('B', new MoneyCollection([new Dollar()])) ); @@ -37,7 +37,7 @@ public function testShouldCalculateRestAndReturnResponseWithCorrectAmount(): voi $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); - $result = $buyItemCommand->execute( + $result = $buyItemCommand( new BuyItemRequest('B', new MoneyCollection([new Dollar()])) ); diff --git a/tests/Command/CoinReturnCommandTest.php b/tests/Command/CoinReturnCommandTest.php index 4fedc96..37f332c 100644 --- a/tests/Command/CoinReturnCommandTest.php +++ b/tests/Command/CoinReturnCommandTest.php @@ -17,7 +17,7 @@ public function testShouldReturnInsertedCoinsInRest(): void $command = new CoinReturnCommand(); - $result = $command->execute(new CoinReturnRequest($moneyCollection)); + $result = $command(new CoinReturnRequest($moneyCollection)); self::assertEquals('D, DOLLAR', $result); } From 60a2cb3d74ad86e1211baaf5b0ad797725fd113f Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 30 Jan 2022 08:47:20 +0100 Subject: [PATCH 83/87] ref: run code sniffer quality PSR rules --- composer.json | 4 ++++ src/Command/CoinReturnCommand.php | 2 +- src/Repository/InMemoryItemRepository.php | 2 +- src/Request/CoinReturnRequest.php | 2 +- src/Request/CommandRequest.php | 2 +- src/Response/CoinReturnConsoleResponse.php | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 7450709..fbad632 100644 --- a/composer.json +++ b/composer.json @@ -21,5 +21,9 @@ "VendingMachine\\": "src/", "Tests\\": "tests/" } + }, + "scripts": { + "code-quality": "php ./vendor/bin/phpcs" } + } diff --git a/src/Command/CoinReturnCommand.php b/src/Command/CoinReturnCommand.php index 0f36c67..9592e8f 100644 --- a/src/Command/CoinReturnCommand.php +++ b/src/Command/CoinReturnCommand.php @@ -12,4 +12,4 @@ public function __invoke(CoinReturnRequest $request): Response { return (new CoinReturnConsoleResponse($request->moneyCollection())); } -} \ No newline at end of file +} diff --git a/src/Repository/InMemoryItemRepository.php b/src/Repository/InMemoryItemRepository.php index 7240db4..1b0375d 100644 --- a/src/Repository/InMemoryItemRepository.php +++ b/src/Repository/InMemoryItemRepository.php @@ -18,7 +18,7 @@ public function add(Item $item): void public function getItemBySelector(string $selector): ?Item { - $filtered = array_filter($this->items, static function(Item $item) use ($selector) { + $filtered = array_filter($this->items, static function (Item $item) use ($selector) { return $item->selector() === $selector; }); diff --git a/src/Request/CoinReturnRequest.php b/src/Request/CoinReturnRequest.php index dcb3c12..97786ae 100644 --- a/src/Request/CoinReturnRequest.php +++ b/src/Request/CoinReturnRequest.php @@ -16,4 +16,4 @@ public function moneyCollection(): MoneyCollection { return $this->moneyCollection; } -} \ No newline at end of file +} diff --git a/src/Request/CommandRequest.php b/src/Request/CommandRequest.php index 5c5851b..c923b81 100644 --- a/src/Request/CommandRequest.php +++ b/src/Request/CommandRequest.php @@ -7,4 +7,4 @@ interface CommandRequest { -} \ No newline at end of file +} diff --git a/src/Response/CoinReturnConsoleResponse.php b/src/Response/CoinReturnConsoleResponse.php index f606e3c..9c32130 100644 --- a/src/Response/CoinReturnConsoleResponse.php +++ b/src/Response/CoinReturnConsoleResponse.php @@ -25,4 +25,4 @@ public function __toString() array: array_map(static fn(Money $money) => $money->shortCode(), $this->moneyCollection->money()) ); } -} \ No newline at end of file +} From 7d288cdb802db58cf7b383f5187549a62be327f6 Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 30 Jan 2022 08:54:57 +0100 Subject: [PATCH 84/87] ref: phpstan, undefined abstract class properties --- composer.json | 6 +++--- composer.lock | 20 +++++++++++--------- src/Model/Money.php | 4 ++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index fbad632..297c101 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,13 @@ } ], "require": { - "php": "8.1" + "php": "8.*" }, "require-dev": { "phpunit/phpunit": "^9", "friendsofphp/php-cs-fixer": "^2.16", "squizlabs/php_codesniffer": "^3.5", - "phpstan/phpstan": "^0.12.18" + "phpstan/phpstan": "^1.4" }, "autoload": { "psr-4": { @@ -23,7 +23,7 @@ } }, "scripts": { - "code-quality": "php ./vendor/bin/phpcs" + "code-quality": "php ./vendor/bin/phpcs && php ./vendor/bin/phpstan analyse src tests" } } diff --git a/composer.lock b/composer.lock index d3d50e1..d231e57 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7f1c454425718425faa5ba3388d0932e", + "content-hash": "cc981926c9d7c554348bf561c5e663cd", "packages": [], "packages-dev": [ { @@ -1060,16 +1060,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.99", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + "reference": "89d10839dbfc95eeb7da656578b4a899ad2b59b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/89d10839dbfc95eeb7da656578b4a899ad2b59b1", + "reference": "89d10839dbfc95eeb7da656578b4a899ad2b59b1", "shasum": "" }, "require": { @@ -1085,7 +1085,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1100,7 +1100,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + "source": "https://github.com/phpstan/phpstan/tree/1.4.3" }, "funding": [ { @@ -1120,7 +1120,7 @@ "type": "tidelift" } ], - "time": "2021-09-12T20:09:55+00:00" + "time": "2022-01-28T16:27:17+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4332,7 +4332,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": "8.*" + }, "platform-dev": [], "plugin-api-version": "2.1.0" } diff --git a/src/Model/Money.php b/src/Model/Money.php index daaa332..a473c29 100644 --- a/src/Model/Money.php +++ b/src/Model/Money.php @@ -6,6 +6,10 @@ abstract class Money { + protected string $shortCode = ''; + + protected int $value = 0; + public function shortCode(): string { return $this->shortCode; From 0bbbc1e1845c39ebef83838a120152ce74ba6aaf Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 30 Jan 2022 09:43:58 +0100 Subject: [PATCH 85/87] ref: replace creating money by constructor to static method --- src/Command/BuyItemCommand.php | 2 +- src/Coordinator/PaymentCoordinator.php | 4 ++++ src/Model/AvailableMoney.php | 14 +++++++------- src/Model/Dime.php | 11 ++++++++--- src/Model/Dollar.php | 11 ++++++++--- src/Model/Money.php | 13 ++++++------- src/Model/Nickel.php | 11 ++++++++--- src/Model/Quarter.php | 9 +++++++-- src/Util/InputParser.php | 4 +++- tests/Command/BuyItemCommandTest.php | 4 ++-- tests/Command/CoinReturnCommandTest.php | 2 +- tests/Coordinator/PaymentCoordinatorTest.php | 12 ++++++------ tests/Model/MoneyCollectionTest.php | 8 ++++---- tests/Request/ConsoleRequestTest.php | 4 ++-- tests/Util/InputParserTest.php | 12 ++++++------ tests/VendingMachine/VendingMachineTest.php | 8 ++++---- 16 files changed, 77 insertions(+), 52 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index a0bbec8..4c89057 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -37,6 +37,6 @@ public function __invoke(BuyItemRequest $request): ConsoleResponse ); } - throw new \InvalidArgumentException('Set enough money to buy Item!'); + throw new \InvalidArgumentException(sprintf("Set enough money to buy Item! Item costs %s, but you put in %s", $availableItem->value(), $moneys->count())); } } diff --git a/src/Coordinator/PaymentCoordinator.php b/src/Coordinator/PaymentCoordinator.php index 72f17e2..b38d70c 100644 --- a/src/Coordinator/PaymentCoordinator.php +++ b/src/Coordinator/PaymentCoordinator.php @@ -22,6 +22,10 @@ public function pay(int $input, int $cost): MoneyCollection throw new \InvalidArgumentException('No enough money to pay for it!'); } + /** + * @param array $coins + * @return array + */ private function calculateRest(int $rest, array $coins): array { $coinRest = []; diff --git a/src/Model/AvailableMoney.php b/src/Model/AvailableMoney.php index d994a1c..637ca97 100644 --- a/src/Model/AvailableMoney.php +++ b/src/Model/AvailableMoney.php @@ -9,19 +9,19 @@ final class AvailableMoney public static function getMoney(): array { return [ - new Nickel(), - new Dime(), - new Quarter(), - new Dollar() + Nickel::create(), + Dime::create(), + Quarter::create(), + Dollar::create() ]; } public static function coins() { return [ - new Nickel(), - new Dime(), - new Quarter(), + Nickel::create(), + Dime::create(), + Quarter::create(), ]; } diff --git a/src/Model/Dime.php b/src/Model/Dime.php index 8c104c4..bf9fb82 100644 --- a/src/Model/Dime.php +++ b/src/Model/Dime.php @@ -4,9 +4,14 @@ namespace VendingMachine\Model; -final class Dime extends Money implements Coin +final class Dime extends Money implements Coin, MoneyCreationInterface { - protected string $shortCode = 'D'; + protected const SHORT_CODE = 'D'; - protected int $value = 10; + protected const VALUE = 10; + + public static function create(): Dime + { + return new Dime(self::SHORT_CODE, self::VALUE); + } } diff --git a/src/Model/Dollar.php b/src/Model/Dollar.php index 08fa0ab..1cd14bc 100644 --- a/src/Model/Dollar.php +++ b/src/Model/Dollar.php @@ -4,9 +4,14 @@ namespace VendingMachine\Model; -final class Dollar extends Money implements PaperMoney +final class Dollar extends Money implements PaperMoney, MoneyCreationInterface { - protected string $shortCode = 'DOLLAR'; + protected const SHORT_CODE = 'DOLLAR'; - protected int $value = 100; + protected const VALUE = 100; + + public static function create(): Dollar + { + return new Dollar(self::SHORT_CODE, self::VALUE); + } } diff --git a/src/Model/Money.php b/src/Model/Money.php index a473c29..b3230c6 100644 --- a/src/Model/Money.php +++ b/src/Model/Money.php @@ -6,9 +6,13 @@ abstract class Money { - protected string $shortCode = ''; + protected const SHORT_CODE = ''; - protected int $value = 0; + protected const VALUE = 0; + + public function __construct(protected string $shortCode, protected int $value) + { + } public function shortCode(): string { @@ -19,9 +23,4 @@ public function value(): int { return $this->value; } - - public function create(): Money - { - return new static(); - } } diff --git a/src/Model/Nickel.php b/src/Model/Nickel.php index 1b16395..89fb978 100644 --- a/src/Model/Nickel.php +++ b/src/Model/Nickel.php @@ -4,9 +4,14 @@ namespace VendingMachine\Model; -final class Nickel extends Money implements Coin +final class Nickel extends Money implements Coin, MoneyCreationInterface { - protected string $shortCode = 'N'; + protected const SHORT_CODE = 'N'; - protected int $value = 5; + protected const VALUE = 5; + + public static function create(): Nickel + { + return new Nickel(self::SHORT_CODE, self::VALUE); + } } diff --git a/src/Model/Quarter.php b/src/Model/Quarter.php index 520085d..26a8b41 100644 --- a/src/Model/Quarter.php +++ b/src/Model/Quarter.php @@ -6,7 +6,12 @@ class Quarter extends Money implements Coin { - protected string $shortCode = 'Q'; + protected const SHORT_CODE = 'Q'; - protected int $value = 25; + protected const VALUE = 25; + + public static function create(): Quarter + { + return new Quarter(self::SHORT_CODE, self::VALUE); + } } diff --git a/src/Util/InputParser.php b/src/Util/InputParser.php index 9724741..9383ed3 100644 --- a/src/Util/InputParser.php +++ b/src/Util/InputParser.php @@ -4,7 +4,9 @@ namespace VendingMachine\Util; +use VendingMachine\Request\ConsoleRequest; + interface InputParser { - public function parse(string $input); + public function parse(string $input): ConsoleRequest; } diff --git a/tests/Command/BuyItemCommandTest.php b/tests/Command/BuyItemCommandTest.php index 3e56f65..a8e64ff 100644 --- a/tests/Command/BuyItemCommandTest.php +++ b/tests/Command/BuyItemCommandTest.php @@ -24,7 +24,7 @@ public function testShouldReturnBoughtBItem(): void $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); $result = $buyItemCommand( - new BuyItemRequest('B', new MoneyCollection([new Dollar()])) + new BuyItemRequest('B', new MoneyCollection([Dollar::create()])) ); self::assertInstanceOf(ConsoleResponse::class, $result); @@ -38,7 +38,7 @@ public function testShouldCalculateRestAndReturnResponseWithCorrectAmount(): voi $buyItemCommand = new BuyItemCommand($itemRepository, new PaymentCoordinator(), new ConsoleResponse()); $result = $buyItemCommand( - new BuyItemRequest('B', new MoneyCollection([new Dollar()])) + new BuyItemRequest('B', new MoneyCollection([Dollar::create(),])) ); self::assertEquals(0, $result->rest()->count()); diff --git a/tests/Command/CoinReturnCommandTest.php b/tests/Command/CoinReturnCommandTest.php index 37f332c..a74b23b 100644 --- a/tests/Command/CoinReturnCommandTest.php +++ b/tests/Command/CoinReturnCommandTest.php @@ -13,7 +13,7 @@ class CoinReturnCommandTest extends TestCase { public function testShouldReturnInsertedCoinsInRest(): void { - $moneyCollection = new MoneyCollection([new Dime(), new Dollar()]); + $moneyCollection = new MoneyCollection([Dime::create(), Dollar::create()]); $command = new CoinReturnCommand(); diff --git a/tests/Coordinator/PaymentCoordinatorTest.php b/tests/Coordinator/PaymentCoordinatorTest.php index df92e27..15f7d2b 100644 --- a/tests/Coordinator/PaymentCoordinatorTest.php +++ b/tests/Coordinator/PaymentCoordinatorTest.php @@ -34,8 +34,8 @@ public function testShouldReturnRestInTwoQuarter(): void self::assertEquals(50, $rest->count()); self::assertEquals( [ - new Quarter(), - new Quarter() + Quarter::create(), + Quarter::create() ], $rest->money() ); @@ -48,8 +48,8 @@ public function testShouldReturnRestInTwoDime(): void self::assertEquals(20, $rest->count()); self::assertEquals( [ - new Dime(), - new Dime() + Dime::create(), + Dime::create() ], $rest->money() ); @@ -62,8 +62,8 @@ public function testShouldReturnRestInQuarterAndDime(): void self::assertEquals(35, $rest->count()); self::assertEquals( [ - new Quarter(), - new Dime() + Quarter::create(), + Dime::create() ], $rest->money() ); diff --git a/tests/Model/MoneyCollectionTest.php b/tests/Model/MoneyCollectionTest.php index c369e6c..034bb7b 100644 --- a/tests/Model/MoneyCollectionTest.php +++ b/tests/Model/MoneyCollectionTest.php @@ -14,15 +14,15 @@ public function testShouldProperlySumMoney(): void { $moneyCollection = new MoneyCollection( [ - new Quarter(), - new Quarter() + Quarter::create(), + Quarter::create(), ] ); self::assertEquals(50, $moneyCollection->count()); self::assertEquals([ - new Quarter(), - new Quarter() + Quarter::create(), + Quarter::create() ], $moneyCollection->money()); } } diff --git a/tests/Request/ConsoleRequestTest.php b/tests/Request/ConsoleRequestTest.php index 7a66c8d..a88bbe4 100644 --- a/tests/Request/ConsoleRequestTest.php +++ b/tests/Request/ConsoleRequestTest.php @@ -40,8 +40,8 @@ public function testShouldThrowInvalidArgumentExceptionWhenActionNameIsInvalid() public function testShouldAddMoneyToRequest(): void { $consoleRequest = new ConsoleRequest('GET-B'); - $consoleRequest->addMoney(new Dime()); + $consoleRequest->addMoney(Dime::create()); - self::assertEquals([new Dime()], $consoleRequest->money()); + self::assertEquals([Dime::create()], $consoleRequest->money()); } } diff --git a/tests/Util/InputParserTest.php b/tests/Util/InputParserTest.php index 3f6ee00..2c8a585 100644 --- a/tests/Util/InputParserTest.php +++ b/tests/Util/InputParserTest.php @@ -67,19 +67,19 @@ public function dataSetForParsingMoney(): array [ 'input' => 'Q, Q, Q, Q, GET-B', 'output' => [ - new Quarter(), - new Quarter(), - new Quarter(), - new Quarter(), + Quarter::create(), + Quarter::create(), + Quarter::create(), + Quarter::create(), ], ], [ 'input' => 'Q, GET-B', - 'output' => [new Quarter()] + 'output' => [Quarter::create()] ], [ 'input' => 'N, GET-B', - 'output' => [new Nickel()] + 'output' => [Nickel::create()] ] ]; } diff --git a/tests/VendingMachine/VendingMachineTest.php b/tests/VendingMachine/VendingMachineTest.php index 2af321a..06abbec 100644 --- a/tests/VendingMachine/VendingMachineTest.php +++ b/tests/VendingMachine/VendingMachineTest.php @@ -57,8 +57,8 @@ public function testShouldOrderProductAndGetRest(): void self::assertEquals(35, $response->rest()->count()); self::assertEquals([ - new Quarter(), - new Dime(), + Quarter::create(), + Dime::create(), ], $response->rest()->money()); self::assertEquals('A, Q, D', $response); } @@ -86,8 +86,8 @@ public function testShouldOrderUsingDollarAndGetRestWithOutExactChange(): void self::assertEquals(35, $response->rest()->count()); self::assertEquals([ - new Quarter(), - new Dime(), + Quarter::create(), + Dime::create(), ], $response->rest()->money()); self::assertEquals('A, Q, D', $response); } From 6647d442ae443a340b315ba232db4d668324f36f Mon Sep 17 00:00:00 2001 From: MarcinGladkowski Date: Sun, 30 Jan 2022 09:46:51 +0100 Subject: [PATCH 86/87] ref: money creation interface --- src/Model/Money.php | 2 +- src/Model/MoneyCreationInterface.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/Model/MoneyCreationInterface.php diff --git a/src/Model/Money.php b/src/Model/Money.php index b3230c6..fb61056 100644 --- a/src/Model/Money.php +++ b/src/Model/Money.php @@ -4,7 +4,7 @@ namespace VendingMachine\Model; -abstract class Money +abstract class Money implements MoneyCreationInterface { protected const SHORT_CODE = ''; diff --git a/src/Model/MoneyCreationInterface.php b/src/Model/MoneyCreationInterface.php new file mode 100644 index 0000000..b410184 --- /dev/null +++ b/src/Model/MoneyCreationInterface.php @@ -0,0 +1,10 @@ + Date: Sun, 30 Jan 2022 09:49:28 +0100 Subject: [PATCH 87/87] ref: formatting code --- src/Command/BuyItemCommand.php | 4 +++- src/Model/MoneyCreationInterface.php | 2 +- src/VendingMachine.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Command/BuyItemCommand.php b/src/Command/BuyItemCommand.php index 4c89057..eddb017 100644 --- a/src/Command/BuyItemCommand.php +++ b/src/Command/BuyItemCommand.php @@ -37,6 +37,8 @@ public function __invoke(BuyItemRequest $request): ConsoleResponse ); } - throw new \InvalidArgumentException(sprintf("Set enough money to buy Item! Item costs %s, but you put in %s", $availableItem->value(), $moneys->count())); + throw new \InvalidArgumentException( + sprintf("Set enough money to buy Item! Needed %s put: %s", $availableItem->value(), $moneys->count()) + ); } } diff --git a/src/Model/MoneyCreationInterface.php b/src/Model/MoneyCreationInterface.php index b410184..1e1879a 100644 --- a/src/Model/MoneyCreationInterface.php +++ b/src/Model/MoneyCreationInterface.php @@ -7,4 +7,4 @@ interface MoneyCreationInterface { public static function create(): Money; -} \ No newline at end of file +} diff --git a/src/VendingMachine.php b/src/VendingMachine.php index f2af319..5d150bf 100644 --- a/src/VendingMachine.php +++ b/src/VendingMachine.php @@ -28,7 +28,7 @@ public function __construct(ItemRepository $itemRepository, InputParser $inputPa $this->inputParser = $inputParser; } - public function execute(string $input): Response + public function execute(string $input): Response|ConsoleRequest { $request = $this->parseInput($input);