From 2877588f5a9a2075f4e996ebae9a355216c8730f Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Mon, 21 Jul 2025 20:42:37 +0200 Subject: [PATCH 1/9] Update dependencies and refine CI workflow Adjusted `composer.json` with updated versions for development dependencies and modified the GitHub actions workflow to remove `PHP_CS_FIXER_IGNORE_ENV` for `cs-check`. Signed-off-by: Marcel Strahl --- .github/workflows/ci.yml | 2 +- composer.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a29b82..360a082 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: run: "composer test" - name: "Run PHP CS Check" - run: "PHP_CS_FIXER_IGNORE_ENV=1 composer cs-check" + run: "composer cs-check" - name: "Run Psalm" run: "composer psalm" diff --git a/composer.json b/composer.json index 93c3cfa..4477c10 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ "ext-bcmath": "*" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.68", - "infection/infection": "0.27.10|^0.29.10", + "friendsofphp/php-cs-fixer": "^3.84", + "infection/infection": "0.27.10|^0.29.14", "phpstan/extension-installer": "*", "phpunit/phpunit": "^10.5 | ^11.5", "psalm/plugin-phpunit": "^0.19", - "squizlabs/php_codesniffer": "^3.11", - "vimeo/psalm": "^5.0|^6.0" + "squizlabs/php_codesniffer": "^3.13", + "vimeo/psalm": "^5.0|^6.13" }, "autoload": { "psr-4": { From 2be7dd9758caa9ba95211179d8a3462ba440bc77 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 13:21:50 +0200 Subject: [PATCH 2/9] modernize workflow and php code Signed-off-by: Marcel Strahl --- .github/workflows/ci.yml | 306 +++++++++--------- composer.json | 15 +- phpmd.xml.dist | 75 +++++ .../PriceCalculatorFactoryException.php | 4 +- src/Facade/UnitConverter.php | 2 +- src/Facade/VatCalculator.php | 4 +- src/Factory/Converter.php | 2 +- .../Converter/Currencies/CentToEuro.php | 4 +- .../Converter/Currencies/EuroToCent.php | 4 +- src/PriceCalculator.php | 10 +- src/Service/DiscountCalculator.php | 19 +- src/Service/VatCalculator.php | 12 +- src/UnitConverter.php | 2 +- .../PriceCalculatorFactoryExceptionTest.php | 8 +- tests/Facade/PriceCalculatorTest.php | 4 +- tests/Facade/UnitConverterTest.php | 4 +- tests/Facade/VatCalculatorTest.php | 6 +- tests/Factory/ConverterFactoryTest.php | 25 +- tests/Feature/AddPriceTest.php | 42 +-- tests/Feature/DiscountCalculationTest.php | 24 +- tests/Feature/DivPriceTest.php | 34 +- tests/Feature/MulPriceTest.php | 40 +-- tests/Feature/SubPriceTest.php | 48 +-- tests/Feature/VatCalculationTest.php | 44 +-- .../Converter/Currencies/CentToEuroTest.php | 26 +- .../Converter/Currencies/EuroToCentTest.php | 26 +- tests/Helpers/Entity/DiscountTest.php | 9 +- tests/Helpers/View/PriceFormatterTest.php | 56 +++- tests/PriceCalculatorTest.php | 158 ++++----- tests/Service/DiscountCalculatorTest.php | 60 ++-- tests/Service/VatCalculatorTest.php | 110 ++++--- tests/UnitConverterTest.php | 15 +- 32 files changed, 708 insertions(+), 490 deletions(-) create mode 100644 phpmd.xml.dist diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 360a082..23dcdd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,148 +7,164 @@ on: - master jobs: - php81: - name: PHP 8.1 - runs-on: ubuntu-latest - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - fetch-depth: 2 - - - name: "Install PHP 8.1" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.1" - - - name: "Cache composer packages" - uses: "actions/cache@v4" - with: - path: "~/.composer/cache" - key: "php-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: "php-composer-locked-" - - - name: "Install dependencies with composer" - run: "composer install --no-interaction" - - - name: "Run PHPUnit Tests" - run: "composer test" - - - name: "Run PHP CS Check" - run: "composer cs-check" - - - name: "Run Psalm" - run: "composer psalm" - - - name: "Run infection" - run: "composer infection-ci" - - php82: - name: PHP 8.2 - runs-on: ubuntu-latest - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - fetch-depth: 2 - - - name: "Install PHP 8.2" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.2" - - - name: "Cache composer packages" - uses: "actions/cache@v4" - with: - path: "~/.composer/cache" - key: "php-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: "php-composer-locked-" - - - name: "Install dependencies with composer" - run: "composer install --no-interaction" - - - name: "Run PHPUnit Tests" - run: "composer test" - - - name: "Run PHP CS Check" - run: "composer cs-check" - - - name: "Run Psalm" - run: "composer psalm" - - - name: "Run infection" - run: "composer infection-ci" - - php83: - name: PHP 8.3 - runs-on: ubuntu-latest - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - fetch-depth: 2 - - - name: "Install PHP 8.3" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.3" - - - name: "Cache composer packages" - uses: "actions/cache@v4" - with: - path: "~/.composer/cache" - key: "php-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: "php-composer-locked-" - - - name: "Install dependencies with composer" - run: "composer install --no-interaction" - - - name: "Run PHPUnit Tests" - run: "composer test" - - - name: "Run PHP CS Check" - run: "composer cs-check" - - - name: "Run Psalm" - run: "composer psalm" - - - name: "Run infection" - env: - INFECTION_BADGE_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - run: "composer infection-ci" - - php84: - name: PHP 8.4 - runs-on: ubuntu-latest - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - fetch-depth: 2 - - - name: "Install PHP 8.4" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.4" - - - name: "Cache composer packages" - uses: "actions/cache@v4" - with: - path: "~/.composer/cache" - key: "php-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: "php-composer-locked-" - - - name: "Install dependencies with composer" - run: "composer install --no-interaction" - - - name: "Run PHPUnit Tests" - run: "composer test" - - - name: "Run PHP CS Check" - run: "composer cs-check" - - - name: "Run Psalm" - run: "composer psalm" - - - name: "Run infection" - run: "composer infection-ci" + phpunit: + name: "PHP ${{ matrix.php }} - PHPUnit" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.1', '8.2', '8.3', '8.4' ] + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 2 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: "Cache composer packages" + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: php-composer-locked-${{ hashFiles('composer.lock') }} + restore-keys: php-composer-locked- + + - name: "Install dependencies" + run: composer install --no-interaction + + - name: "Run PHPUnit Tests" + run: composer test + + cs: + name: "PHP ${{ matrix.php }} - CS Check" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.1', '8.2', '8.3', '8.4' ] + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 2 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: "Cache composer packages" + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: php-composer-locked-${{ hashFiles('composer.lock') }} + restore-keys: php-composer-locked- + + - name: "Install dependencies" + run: composer install --no-interaction + + - name: "Run PHP CS Check" + run: composer cs-check + + phpmd: + name: "PHP ${{ matrix.php }} - PHP Mess Detector" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.1', '8.2', '8.3', '8.4' ] + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 2 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: "Cache composer packages" + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: php-composer-locked-${{ hashFiles('composer.lock') }} + restore-keys: php-composer-locked- + + - name: "Install dependencies" + run: composer install --no-interaction + + - name: "Run PHP Mess Detector" + run: composer phpmd + + psalm: + name: "PHP ${{ matrix.php }} - Psalm" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.1', '8.2', '8.3', '8.4' ] + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 2 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: "Cache composer packages" + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: php-composer-locked-${{ hashFiles('composer.lock') }} + restore-keys: php-composer-locked- + + - name: "Install dependencies" + run: composer install --no-interaction + + - name: "Run Psalm" + run: composer psalm + + infection: + name: "PHP ${{ matrix.php }} - Infection" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.1', '8.2', '8.3', '8.4' ] + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 2 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: "Cache composer packages" + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: php-composer-locked-${{ hashFiles('composer.lock') }} + restore-keys: php-composer-locked- + + - name: "Install dependencies" + run: composer install --no-interaction + + - name: "Run infection (with badge upload)" + if: matrix.php == '8.3' + env: + INFECTION_BADGE_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + run: composer infection-ci + + - name: "Run infection" + if: matrix.php != '8.3' + run: composer infection-ci diff --git a/composer.json b/composer.json index 4477c10..2fc754d 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ "ext-bcmath": "*" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.84", - "infection/infection": "0.27.10|^0.29.14", + "friendsofphp/php-cs-fixer": "^3.87", + "infection/infection": "^0.27", "phpstan/extension-installer": "*", - "phpunit/phpunit": "^10.5 | ^11.5", + "phpunit/phpunit": "^10.5", "psalm/plugin-phpunit": "^0.19", - "squizlabs/php_codesniffer": "^3.13", - "vimeo/psalm": "^5.0|^6.13" + "phpmd/phpmd": "^2.15", + "vimeo/psalm": "^5.26" }, "autoload": { "psr-4": { @@ -39,18 +39,17 @@ }, "prefer-stable": true, "scripts": { - "phpcs": "phpcs --standard=phpcs.xml.dist", "cs-check": "php-cs-fixer -v --dry-run --using-cache=no fix", "cs-fix": "php-cs-fixer --using-cache=no fix", + "phpmd": "vendor/bin/phpmd src,tests text phpmd.xml.dist", "test": "export XDEBUG_MODE=coverage && phpunit -c phpunit.xml --coverage-xml build/logs --coverage-clover build/logs/clover.xml --coverage-html build/logs/clover.html --log-junit build/logs/junit.xml", "psalm": "vendor/bin/psalm --no-cache", "infection": "infection --threads=4", "infection-ci": "infection --coverage=build/logs --threads=4", "check": [ - "@phpcs", "@cs-check", + "@phpmd", "@psalm", - "@analyze", "@test" ] } diff --git a/phpmd.xml.dist b/phpmd.xml.dist new file mode 100644 index 0000000..92422f5 --- /dev/null +++ b/phpmd.xml.dist @@ -0,0 +1,75 @@ + + + + + PHPMD configuration for the PriceCalculator project. + Targets PHP 8.1+ and aims for pragmatic, readable library code. + This ruleset is intentionally balanced to reduce noise while catching real issues. + + + + vendor/.* + build/.* + docs/.* + \.phpstorm\.meta\.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Exceptions/PriceCalculatorFactoryException.php b/src/Exceptions/PriceCalculatorFactoryException.php index f59a6c7..dd90214 100644 --- a/src/Exceptions/PriceCalculatorFactoryException.php +++ b/src/Exceptions/PriceCalculatorFactoryException.php @@ -13,10 +13,12 @@ */ class PriceCalculatorFactoryException extends InvalidArgumentException { + private const MESSAGE = 'The required currency translation is not currently supported. Type: %s'; + public static function fromUnsupportedArgument(string $type): self { return new self( - sprintf('The required currency translation is not currently supported. Type: %s', $type), + sprintf(self::MESSAGE, $type), 500 ); } diff --git a/src/Facade/UnitConverter.php b/src/Facade/UnitConverter.php index 3a02868..d5d92c0 100644 --- a/src/Facade/UnitConverter.php +++ b/src/Facade/UnitConverter.php @@ -25,7 +25,7 @@ public static function getConverter(): UnitConverterService */ private function createUnitConverter(): UnitConverterService { - return new UnitConverterService($this->createFactory()); + return new UnitConverterService(factory: $this->createFactory()); } /** diff --git a/src/Facade/VatCalculator.php b/src/Facade/VatCalculator.php index 129e6ab..2d29c05 100644 --- a/src/Facade/VatCalculator.php +++ b/src/Facade/VatCalculator.php @@ -19,11 +19,11 @@ private function __construct(private Vat $vat, private PriceCalculatorInterface public static function getVatCalculator(int $vat): VatCalculatorService { - return (new self(Vat::create($vat), PriceCalculator::getPriceCalculator()))->createVatCalculator(); + return (new self(vat: Vat::create(vat: $vat), priceCalculator: PriceCalculator::getPriceCalculator()))->createVatCalculator(); } private function createVatCalculator(): VatCalculatorService { - return new VatCalculatorService($this->vat, $this->priceCalculator); + return new VatCalculatorService(vat: $this->vat, priceCalculator: $this->priceCalculator); } } diff --git a/src/Factory/Converter.php b/src/Factory/Converter.php index 1aa4ec1..c43bac0 100644 --- a/src/Factory/Converter.php +++ b/src/Factory/Converter.php @@ -23,7 +23,7 @@ public function factorize(string $destinationUnit): ConverterInterface return match ($destinationUnit) { ConverterFactoryInterface::CENT_TO_EURO => new CentToEuro(), ConverterFactoryInterface::EURO_TO_CENT => new EuroToCent(), - default => throw PriceCalculatorFactoryException::fromUnsupportedArgument($destinationUnit), + default => throw PriceCalculatorFactoryException::fromUnsupportedArgument(type: $destinationUnit), }; } } diff --git a/src/Helpers/Converter/Currencies/CentToEuro.php b/src/Helpers/Converter/Currencies/CentToEuro.php index b1062dc..ce570da 100644 --- a/src/Helpers/Converter/Currencies/CentToEuro.php +++ b/src/Helpers/Converter/Currencies/CentToEuro.php @@ -17,11 +17,11 @@ class CentToEuro implements ConverterInterface */ public function convert(float $amount): float { - if ($this->isEmpty($amount)) { + if ($this->isEmpty(amount: $amount)) { return FiguresInterface::FLOAT_ZERO; } - return (float) bcdiv((string) $amount, FiguresInterface::STRING_HUNDRED, FiguresInterface::INTEGER_TWO); + return (float) bcdiv(num1: (string) $amount, num2: FiguresInterface::STRING_HUNDRED, scale: FiguresInterface::INTEGER_TWO); } /** diff --git a/src/Helpers/Converter/Currencies/EuroToCent.php b/src/Helpers/Converter/Currencies/EuroToCent.php index 65d21fb..df404f1 100644 --- a/src/Helpers/Converter/Currencies/EuroToCent.php +++ b/src/Helpers/Converter/Currencies/EuroToCent.php @@ -17,11 +17,11 @@ class EuroToCent implements ConverterInterface */ public function convert(float $amount): float { - if ($this->isEmpty($amount)) { + if ($this->isEmpty(amount: $amount)) { return FiguresInterface::FLOAT_ZERO; } - return (float) bcmul((string) $amount, FiguresInterface::STRING_HUNDRED); + return (float) bcmul(num1: (string) $amount, num2: FiguresInterface::STRING_HUNDRED); } /** diff --git a/src/PriceCalculator.php b/src/PriceCalculator.php index e95ede9..95e24ed 100644 --- a/src/PriceCalculator.php +++ b/src/PriceCalculator.php @@ -26,11 +26,11 @@ public function addPrice(Price $total, Price $price): Price */ public function subPrice(Price $total, Price $price): Price { - $calculated = Price::create($total->getPrice() - $price->getPrice()); + $calculated = Price::create(price: $total->getPrice() - $price->getPrice()); /** @infection-ignore-all */ if ($calculated->getPrice() < FiguresInterface::INTEGER_ZERO) { - return Price::create(FiguresInterface::INTEGER_ZERO); + return Price::create(price: FiguresInterface::INTEGER_ZERO); } return $calculated; @@ -41,7 +41,7 @@ public function subPrice(Price $total, Price $price): Price */ public function mulPrice(Price $amount, Price $price): Price { - return Price::create($price->getPrice() * $amount->getPrice()); + return Price::create(price: $price->getPrice() * $amount->getPrice()); } /** @@ -50,9 +50,9 @@ public function mulPrice(Price $amount, Price $price): Price public function divPrice(int $amount, Price $price): Price { if ($amount <= FiguresInterface::INTEGER_ZERO) { - return Price::create(FiguresInterface::INTEGER_ZERO); + return Price::create(price: FiguresInterface::INTEGER_ZERO); } - return Price::create((int) ($price->getPrice() / $amount)); + return Price::create(price: (int) ($price->getPrice() / $amount)); } } diff --git a/src/Service/DiscountCalculator.php b/src/Service/DiscountCalculator.php index fda8e0b..fd62972 100644 --- a/src/Service/DiscountCalculator.php +++ b/src/Service/DiscountCalculator.php @@ -17,6 +17,8 @@ */ class DiscountCalculator implements DiscountCalculatorInterface { + private const NEEDLE_FLOAT_SEPARATOR = '.'; + /** * @param Price $total * @param Discount $discount @@ -24,11 +26,12 @@ class DiscountCalculator implements DiscountCalculatorInterface */ public function calculateDiscountFromTotal(Price $total, Discount $discount): Price { - if (($discountPrice = $this->calculateDiscountPriceFromTotal($total, $discount))->getPrice() === FiguresInterface::INTEGER_ZERO) { + $discountPrice = $this->calculateDiscountPriceFromTotal(total: $total, discount: $discount); + if ($discountPrice->getPrice() === FiguresInterface::INTEGER_ZERO) { return $discountPrice; } - return Price::create($total->getPrice() - $discountPrice->getPrice()); + return Price::create(price: $total->getPrice() - $discountPrice->getPrice()); } /** @@ -39,23 +42,23 @@ public function calculateDiscountFromTotal(Price $total, Discount $discount): Pr public function calculateDiscountPriceFromTotal(Price $total, Discount $discount): Price { if ($total->getPrice() === FiguresInterface::INTEGER_ZERO) { - return Price::create(FiguresInterface::INTEGER_ZERO); + return Price::create(price: FiguresInterface::INTEGER_ZERO); } $totalPrice = $total->getPrice() / FiguresInterface::INTEGER_HUNDRED; $calculatedAmount = $totalPrice * $discount->getDiscount(); - $foundAmount = strstr((string) $calculatedAmount, '.'); + $foundAmount = strstr(haystack: (string) $calculatedAmount, needle: self::NEEDLE_FLOAT_SEPARATOR); - if (!is_string($foundAmount)) { - return Price::create((int) $calculatedAmount); + if (!is_string(value: $foundAmount)) { + return Price::create(price: (int) $calculatedAmount); } $calculatedAmount /= FiguresInterface::INTEGER_HUNDRED; - $calculatedAmount = round($calculatedAmount, FiguresInterface::INTEGER_TWO); + $calculatedAmount = round(num: $calculatedAmount, precision: FiguresInterface::INTEGER_TWO); $calculatedAmount *= FiguresInterface::INTEGER_HUNDRED; - return Price::create((int) $calculatedAmount); + return Price::create(price: (int) $calculatedAmount); } } diff --git a/src/Service/VatCalculator.php b/src/Service/VatCalculator.php index d49e5f8..70cf68e 100644 --- a/src/Service/VatCalculator.php +++ b/src/Service/VatCalculator.php @@ -37,7 +37,7 @@ public function calculatePriceWithSalesTax(Price $netPrice): Price $grossPrice = $netPrice->getPrice() + $vatPrice; // Calculate to Euro for round the number if necessary $grossPrice /= FiguresInterface::INTEGER_HUNDRED; - $grossPrice = round($grossPrice, FiguresInterface::INTEGER_TWO); + $grossPrice = round(num: $grossPrice, precision: FiguresInterface::INTEGER_TWO); // Calculate to cent to be had an int $grossPrice *= FiguresInterface::INTEGER_HUNDRED; @@ -48,9 +48,9 @@ public function calculatePriceWithSalesTax(Price $netPrice): Price * A workaround here is to use round again with precision 0 and then use a safe carst to integer. */ /** @infection-ignore-all */ - $grossPrice = (int) round($grossPrice); + $grossPrice = (int) round(num: $grossPrice); - return Price::create($grossPrice); + return Price::create(price: $grossPrice); } /** @@ -61,15 +61,15 @@ public function calculatePriceWithSalesTax(Price $netPrice): Price */ public function calculateSalesTaxFromTotalPrice(Price $total): Price { - $toCalculatingVatPrice = Price::create($total->getPrice()); + $toCalculatingVatPrice = Price::create(price: $total->getPrice()); $vatToCalculate = FiguresInterface::INTEGER_ONE + ($this->vat->getVat() / FiguresInterface::INTEGER_HUNDRED); - $calculatedPrice = (int) (round($toCalculatingVatPrice->getPrice() / $vatToCalculate, FiguresInterface::INTEGER_ZERO)); + $calculatedPrice = (int) (round(num: $toCalculatingVatPrice->getPrice() / $vatToCalculate, precision: FiguresInterface::INTEGER_ZERO)); $calculatedPrice = $total->getPrice() - $calculatedPrice; - return Price::create($calculatedPrice); + return Price::create(price: $calculatedPrice); } /** diff --git a/src/UnitConverter.php b/src/UnitConverter.php index 2baf2bc..05ef7d5 100644 --- a/src/UnitConverter.php +++ b/src/UnitConverter.php @@ -31,6 +31,6 @@ public function __construct(ConverterFactoryInterface $factory) */ public function convert(string $destinationUnit): ConverterInterface { - return $this->factory->factorize($destinationUnit); + return $this->factory->factorize(destinationUnit: $destinationUnit); } } diff --git a/tests/Exceptions/PriceCalculatorFactoryExceptionTest.php b/tests/Exceptions/PriceCalculatorFactoryExceptionTest.php index db35bbb..8fa6999 100644 --- a/tests/Exceptions/PriceCalculatorFactoryExceptionTest.php +++ b/tests/Exceptions/PriceCalculatorFactoryExceptionTest.php @@ -14,12 +14,12 @@ final class PriceCalculatorFactoryExceptionTest extends TestCase #[Test] public function canCreateException(): void { - $exception = PriceCalculatorFactoryException::fromUnsupportedArgument('test'); + $exception = PriceCalculatorFactoryException::fromUnsupportedArgument(type: 'test'); - $this->assertSame(500, $exception->getCode()); + $this->assertSame(expected: 500, actual: $exception->getCode()); $this->assertSame( - 'The required currency translation is not currently supported. Type: test', - $exception->getMessage() + expected: 'The required currency translation is not currently supported. Type: test', + actual: $exception->getMessage() ); } } diff --git a/tests/Facade/PriceCalculatorTest.php b/tests/Facade/PriceCalculatorTest.php index ba78484..401d03d 100644 --- a/tests/Facade/PriceCalculatorTest.php +++ b/tests/Facade/PriceCalculatorTest.php @@ -20,7 +20,7 @@ final class PriceCalculatorTest extends TestCase public function canInitPriceCalculatorFacade(): void { $facade = new PriceCalculatorFacade(); - $this->assertInstanceOf(PriceCalculatorFacade::class, $facade); + $this->assertInstanceOf(expected: PriceCalculatorFacade::class, actual: $facade); } #[Test] @@ -29,6 +29,6 @@ public function canGetPriceCalculator(): void $facade = new PriceCalculatorFacade(); $priceCalculator = $facade::getPriceCalculator(); - $this->assertInstanceOf(PriceCalculatorInterface::class, $priceCalculator); + $this->assertInstanceOf(expected: PriceCalculatorInterface::class, actual: $priceCalculator); } } diff --git a/tests/Facade/UnitConverterTest.php b/tests/Facade/UnitConverterTest.php index 831df0b..2833d7e 100644 --- a/tests/Facade/UnitConverterTest.php +++ b/tests/Facade/UnitConverterTest.php @@ -23,7 +23,7 @@ final class UnitConverterTest extends TestCase public function canInitPriceCalculatorFacade(): void { $facade = new UnitConverterFacade(); - $this->assertInstanceOf(UnitConverterFacade::class, $facade); + $this->assertInstanceOf(expected: UnitConverterFacade::class, actual: $facade); } #[Test] @@ -32,6 +32,6 @@ public function canGetUnitConverter(): void $facade = new UnitConverterFacade(); $unitConverter = $facade::getConverter(); - $this->assertInstanceOf(UnitConverterInterface::class, $unitConverter); + $this->assertInstanceOf(expected: UnitConverterInterface::class, actual: $unitConverter); } } diff --git a/tests/Facade/VatCalculatorTest.php b/tests/Facade/VatCalculatorTest.php index de2ed0e..e0c1aa9 100644 --- a/tests/Facade/VatCalculatorTest.php +++ b/tests/Facade/VatCalculatorTest.php @@ -25,11 +25,11 @@ final class VatCalculatorTest extends TestCase #[Test] public function canInitVatCalculatorFacade(): void { - $vatCalculator = VatCalculatorFacade::getVatCalculator(19); + $vatCalculator = VatCalculatorFacade::getVatCalculator(vat: 19); $this->assertInstanceOf( - VatCalculator::class, - $vatCalculator + expected: VatCalculator::class, + actual: $vatCalculator, ); } } diff --git a/tests/Factory/ConverterFactoryTest.php b/tests/Factory/ConverterFactoryTest.php index 71b5136..695a990 100644 --- a/tests/Factory/ConverterFactoryTest.php +++ b/tests/Factory/ConverterFactoryTest.php @@ -26,8 +26,8 @@ final class ConverterFactoryTest extends TestCase public function hasImplemented(): void { $converterFactory = new Converter(); - $this->assertInstanceOf(ConverterFactoryInterface::class, $converterFactory); - $this->assertInstanceOf(Converter::class, $converterFactory); + $this->assertInstanceOf(expected: ConverterFactoryInterface::class, actual: $converterFactory); + $this->assertInstanceOf(expected: Converter::class, actual: $converterFactory); } /** @@ -40,9 +40,9 @@ public function testGetConverter(string $destinationUnit, string $expectedClass) $factory = new Converter(); if ($destinationUnit === '') { - $this->expectException(PriceCalculatorFactoryException::class); - $this->expectExceptionCode(500); - $this->expectExceptionMessage('The required currency translation is not currently supported. Type: '); + $this->expectException(exception: PriceCalculatorFactoryException::class); + $this->expectExceptionCode(code: 500); + $this->expectExceptionMessage(message: 'The required currency translation is not currently supported. Type: '); } $converter = $factory->factorize($destinationUnit); @@ -59,9 +59,18 @@ public function testGetConverter(string $destinationUnit, string $expectedClass) public static function dataProviderGetConverter(): array { return [ - [ConverterFactoryInterface::CENT_TO_EURO, CentToEuro::class], - [ConverterFactoryInterface::EURO_TO_CENT, EuroToCent::class], - ['', ''], + [ + ConverterFactoryInterface::CENT_TO_EURO, + CentToEuro::class, + ], + [ + ConverterFactoryInterface::EURO_TO_CENT, + EuroToCent::class, + ], + [ + '', + '', + ], ]; } } diff --git a/tests/Feature/AddPriceTest.php b/tests/Feature/AddPriceTest.php index 480acca..9d2061a 100644 --- a/tests/Feature/AddPriceTest.php +++ b/tests/Feature/AddPriceTest.php @@ -28,7 +28,7 @@ public function setUp(): void parent::setUp(); $this->priceCalculator = PriceCalculator::getPriceCalculator(); - $this->formatter = new PriceFormatter(2, ',', '.', '€'); + $this->formatter = new PriceFormatter(decimals: 2, decPoint: ',', thousandsSep: '.', currency: '€'); } #[Test] @@ -41,19 +41,19 @@ public function canAddCentPrices( ): void { $priceCalculator = PriceCalculator::getPriceCalculator(); - $this->assertInstanceOf(PriceCalculatorInterface::class, $priceCalculator); + $this->assertInstanceOf(expected: PriceCalculatorInterface::class, actual: $priceCalculator); - $calculatedPrice = $priceCalculator->addPrice($total, $addPrice); + $calculatedPrice = $priceCalculator->addPrice(total: $total, price: $addPrice); - $this->assertEquals($expectedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $calculatedPrice->getPrice()); $converter = new CentToEuro(); - $convertedPrice = $converter->convert($calculatedPrice->getPrice()); + $convertedPrice = $converter->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -61,14 +61,14 @@ public function canAddCentPrices( */ public static function dataProviderCanAddCentPrices(): array { - $samePrice = Price::create(300); + $samePrice = Price::create(price: 300); - $firstDifferentPrice = Price::create(149); + $firstDifferentPrice = Price::create(price: 149); - $secondDifferentPrice = Price::create(1034); + $secondDifferentPrice = Price::create(price: 1034); return [ - 'same_first_and_second_price' => [ + 'same_first_and_second_price' => [ $samePrice, $samePrice, 600, @@ -92,22 +92,22 @@ public function canAddEuroPrice( string $expectedFormattedPrice ): void { $euroToCentConverter = new EuroToCent(); - $totalPriceInCent = $euroToCentConverter->convert($total); - $addPriceInCent = $euroToCentConverter->convert($addPrice); + $totalPriceInCent = $euroToCentConverter->convert(amount: $total); + $addPriceInCent = $euroToCentConverter->convert(amount: $addPrice); - $totalPrice = Price::create((int) $totalPriceInCent); - $addPrice = Price::create((int) $addPriceInCent); + $totalPrice = Price::create(price: (int) $totalPriceInCent); + $addPrice = Price::create(price: (int) $addPriceInCent); - $calculatedPrice = $this->priceCalculator->addPrice($totalPrice, $addPrice); + $calculatedPrice = $this->priceCalculator->addPrice(total: $totalPrice, price: $addPrice); - $this->assertEquals($expectedCalculatedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedCalculatedPrice, actual: $calculatedPrice->getPrice()); $centToEuroConverter = new CentToEuro(); - $convertedPrice = $centToEuroConverter->convert($calculatedPrice->getPrice()); + $convertedPrice = $centToEuroConverter->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -119,7 +119,7 @@ public function canAddEuroPrice( public static function dataProviderCanAddEuroPrice(): array { return [ - 'same_price' => [ + 'same_price' => [ 3.00, 3.00, 600, diff --git a/tests/Feature/DiscountCalculationTest.php b/tests/Feature/DiscountCalculationTest.php index 9a3f126..ba50bfc 100644 --- a/tests/Feature/DiscountCalculationTest.php +++ b/tests/Feature/DiscountCalculationTest.php @@ -22,13 +22,13 @@ public function canCalculateDiscountedTotal(int $priceAmount, float $discountAmo { $discountCalculator = new DiscountCalculator(); - $price = Price::create($priceAmount); + $price = Price::create(price: $priceAmount); - $discount = new Discount($discountAmount); + $discount = new Discount(percent: $discountAmount); - $total = $discountCalculator->calculateDiscountFromTotal($price, $discount); + $total = $discountCalculator->calculateDiscountFromTotal(total: $price, discount: $discount); - $this->assertEquals($expectedPrice, $total->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $total->getPrice()); } #[Test] @@ -37,13 +37,13 @@ public function canCalculateDiscountPrice(int $priceAmount, float $discountAmoun { $discountCalculator = new DiscountCalculator(); - $price = Price::create($priceAmount); + $price = Price::create(price: $priceAmount); - $discount = new Discount($discountAmount); + $discount = new Discount(percent: $discountAmount); - $discountPrice = $discountCalculator->calculateDiscountPriceFromTotal($price, $discount); + $discountPrice = $discountCalculator->calculateDiscountPriceFromTotal(total: $price, discount: $discount); - $this->assertEquals($expectedPrice, $discountPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $discountPrice->getPrice()); } /** @@ -119,12 +119,12 @@ public function canCalculateDiscountedTotalPriceWhenDiscountIsHundred(): void { $discountCalculator = new DiscountCalculator(); - $price = Price::create(5034); + $price = Price::create(price: 5034); - $discount = new Discount(100); + $discount = new Discount(percent: 100); - $discountPrice = $discountCalculator->calculateDiscountPriceFromTotal($price, $discount); + $discountPrice = $discountCalculator->calculateDiscountPriceFromTotal(total: $price, discount: $discount); - $this->assertSame(5034, $discountPrice->getPrice()); + $this->assertSame(expected: 5034, actual: $discountPrice->getPrice()); } } diff --git a/tests/Feature/DivPriceTest.php b/tests/Feature/DivPriceTest.php index 2418680..4a629e4 100644 --- a/tests/Feature/DivPriceTest.php +++ b/tests/Feature/DivPriceTest.php @@ -27,7 +27,7 @@ public function setUp(): void { parent::setUp(); $this->priceCalculator = PriceCalculator::getPriceCalculator(); - $this->formatter = new PriceFormatter(2, ',', '.', '€'); + $this->formatter = new PriceFormatter(decimals: 2, decPoint: ',', thousandsSep: '.', currency: '€'); } #[Test] @@ -38,16 +38,16 @@ public function canDivCentPrice( int $expectedPrice, string $expectedFormattedPrice ): void { - $calculatedPrice = $this->priceCalculator->divPrice($amount, $total); + $calculatedPrice = $this->priceCalculator->divPrice(amount: $amount, price: $total); - $this->assertEquals($expectedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $calculatedPrice->getPrice()); $converter = new CentToEuro(); - $convertedPrice = $converter->convert($calculatedPrice->getPrice()); + $convertedPrice = $converter->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -64,13 +64,13 @@ public static function dataProviderCanDivCentPrice(): array $totalPriceIsLowerThanZero = Price::create(0); return [ - 'easy_div_calculation' => [ + 'easy_div_calculation' => [ 9, $easyDivCalculation, 1, '0,01 €', ], - 'different_prices' => [ + 'different_prices' => [ 15, $differentTotalPrice, 0, @@ -95,20 +95,20 @@ public function canDivEuroPrice( ): void { $euroToCent = new EuroToCent(); - $totalInCent = $euroToCent->convert($total); + $totalInCent = $euroToCent->convert(amount: $total); - $totalPrice = Price::create((int) $totalInCent); + $totalPrice = Price::create(price: (int) $totalInCent); - $calculatedPrice = $this->priceCalculator->divPrice($amount, $totalPrice); + $calculatedPrice = $this->priceCalculator->divPrice(amount: $amount, price: $totalPrice); - $this->assertEquals($expectedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $calculatedPrice->getPrice()); $centToEuro = new CentToEuro(); - $convertedPrice = $centToEuro->convert($calculatedPrice->getPrice()); + $convertedPrice = $centToEuro->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -121,13 +121,13 @@ public function canDivEuroPrice( public static function dataProviderCanDivEuroPrice(): array { return [ - 'easy_div_calculation' => [ + 'easy_div_calculation' => [ 9, 0.09, 1, '0,01 €', ], - 'different_prices' => [ + 'different_prices' => [ 15, 0.05, 0, diff --git a/tests/Feature/MulPriceTest.php b/tests/Feature/MulPriceTest.php index 9c3fa09..586be50 100644 --- a/tests/Feature/MulPriceTest.php +++ b/tests/Feature/MulPriceTest.php @@ -26,7 +26,7 @@ public function setUp(): void { parent::setUp(); $this->priceCalculator = PriceCalculator::getPriceCalculator(); - $this->formatter = new PriceFormatter(2, ',', '.', '€'); + $this->formatter = new PriceFormatter(decimals: 2, decPoint: ',', thousandsSep: '.', currency: '€'); } #[Test] @@ -37,16 +37,16 @@ public function canMulCentPrice( int $expectedPrice, string $expectedFormattedPrice ): void { - $calculatedPrice = $this->priceCalculator->mulPrice($amount, $total); + $calculatedPrice = $this->priceCalculator->mulPrice(amount: $amount, price: $total); - $this->assertEquals($expectedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $calculatedPrice->getPrice()); $converter = new CentToEuro(); - $convertedPrice = $converter->convert($calculatedPrice->getPrice()); + $convertedPrice = $converter->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -60,26 +60,26 @@ public function canMulCentPrice( */ public static function dataProviderCanMulCentPrice(): array { - $easyMulCalculation = Price::create(9); - $easyMulCalculationAmount = Price::create(9); - $differentTotalPrice = Price::create(5); - $differentAmount = Price::create(15); - $totalPriceIsLowerThanZero = Price::create(0); - $amountOfIsLowerThanZero = Price::create(9); - $highTotalPrice = Price::create(5000); - $highAmount = Price::create(50000); - $highFloatPriceAmount = Price::create(500); + $easyMulCalculation = Price::create(price: 9); + $easyMulCalculationAmount = Price::create(price: 9); + $differentTotalPrice = Price::create(price: 5); + $differentAmount = Price::create(price: 15); + $totalPriceIsLowerThanZero = Price::create(price: 0); + $amountOfIsLowerThanZero = Price::create(price: 9); + $highTotalPrice = Price::create(price: 5000); + $highAmount = Price::create(price: 50000); + $highFloatPriceAmount = Price::create(price: 500); - $highFloatPriceTotal = Price::create(59596); + $highFloatPriceTotal = Price::create(price: 59596); return [ - 'easy_div_calculation' => [ + 'easy_div_calculation' => [ $easyMulCalculationAmount, $easyMulCalculation, 81, '0,81 €', ], - 'different_prices' => [ + 'different_prices' => [ $differentAmount, $differentTotalPrice, 75, @@ -91,13 +91,13 @@ public static function dataProviderCanMulCentPrice(): array 0, '0,00 €', ], - 'use_high_numbers' => [ + 'use_high_numbers' => [ $highAmount, $highTotalPrice, 250000000, '2.500.000,00 €', ], - 'use_high_float_price' => [ + 'use_high_float_price' => [ $highFloatPriceAmount, $highFloatPriceTotal, 29798000, diff --git a/tests/Feature/SubPriceTest.php b/tests/Feature/SubPriceTest.php index 43b01fc..9d9e775 100644 --- a/tests/Feature/SubPriceTest.php +++ b/tests/Feature/SubPriceTest.php @@ -27,7 +27,7 @@ public function setUp(): void { parent::setUp(); $this->priceCalculator = PriceCalculator::getPriceCalculator(); - $this->formatter = new PriceFormatter(2, ',', '.', '€'); + $this->formatter = new PriceFormatter(decimals: 2, decPoint: ',', thousandsSep: '.', currency: '€'); } #[Test] @@ -38,16 +38,16 @@ public function canSubCentPrice( int $expectedPrice, string $expectedFormattedPrice ): void { - $calculatedPrice = $this->priceCalculator->subPrice($total, $subPrice); + $calculatedPrice = $this->priceCalculator->subPrice(total: $total, price: $subPrice); - $this->assertEquals($expectedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $calculatedPrice->getPrice()); $converter = new CentToEuro(); - $convertedPrice = $converter->convert($calculatedPrice->getPrice()); + $convertedPrice = $converter->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -59,24 +59,24 @@ public function canSubCentPrice( */ public static function dataProviderCanSubCentPrice(): array { - $samePrice = Price::create(12); + $samePrice = Price::create(price: 12); - $differentTotalPrice = Price::create(1500); + $differentTotalPrice = Price::create(price: 1500); - $differentSubPrice = Price::create(1000); + $differentSubPrice = Price::create(price: 1000); - $totalPriceIsLowerThanZero = Price::create(100); + $totalPriceIsLowerThanZero = Price::create(price: 100); - $secondPriceIsLowerThanZero = Price::create(200); + $secondPriceIsLowerThanZero = Price::create(price: 200); return [ - 'same_price' => [ + 'same_price' => [ $samePrice, $samePrice, 0, '0,00 €', ], - 'different_prices' => [ + 'different_prices' => [ $differentTotalPrice, $differentSubPrice, 500, @@ -101,23 +101,23 @@ public function canSubEuroPrice( ): void { $euroToCent = new EuroToCent(); - $totalInCent = $euroToCent->convert($total); - $subPriceInCent = $euroToCent->convert($subPrice); + $totalInCent = $euroToCent->convert(amount: $total); + $subPriceInCent = $euroToCent->convert(amount: $subPrice); - $totalPrice = Price::create((int) $totalInCent); + $totalPrice = Price::create(price: (int) $totalInCent); - $sub = Price::create((int) $subPriceInCent); + $sub = Price::create(price: (int) $subPriceInCent); - $calculatedPrice = $this->priceCalculator->subPrice($totalPrice, $sub); + $calculatedPrice = $this->priceCalculator->subPrice(total: $totalPrice, price: $sub); - $this->assertEquals($expectedPrice, $calculatedPrice->getPrice()); + $this->assertEquals(expected: $expectedPrice, actual: $calculatedPrice->getPrice()); $centToEuro = new CentToEuro(); - $convertedPrice = $centToEuro->convert($calculatedPrice->getPrice()); + $convertedPrice = $centToEuro->convert(amount: $calculatedPrice->getPrice()); - $formattedPrice = $this->formatter->formatPrice($convertedPrice); + $formattedPrice = $this->formatter->formatPrice(price: $convertedPrice); - $this->assertEquals($expectedFormattedPrice, $formattedPrice); + $this->assertEquals(expected: $expectedFormattedPrice, actual: $formattedPrice); } /** @@ -130,13 +130,13 @@ public function canSubEuroPrice( public static function dataProviderCanSubEuroPrice(): array { return [ - 'same_price' => [ + 'same_price' => [ 15.51, 15.51, 0, '0,00 €', ], - 'different_prices' => [ + 'different_prices' => [ 20.85, 19.99, 86, diff --git a/tests/Feature/VatCalculationTest.php b/tests/Feature/VatCalculationTest.php index 1e51589..38ac065 100644 --- a/tests/Feature/VatCalculationTest.php +++ b/tests/Feature/VatCalculationTest.php @@ -23,18 +23,18 @@ public function setUp(): void { parent::setUp(); - $vat = Vat::create(19); + $vat = Vat::create(vat: 19); - $this->vatCalculator = new VatCalculator($vat, new PriceCalculator()); + $this->vatCalculator = new VatCalculator(vat: $vat, priceCalculator: new PriceCalculator()); } #[Test] #[DataProvider(methodName: 'dataProviderCanCalculatePriceWithSalesTax')] public function canCalculatePriceWithSalesTax(Price $netPrice, Price $expectedGrossPrice): void { - $grossPrice = $this->vatCalculator->calculatePriceWithSalesTax($netPrice); + $grossPrice = $this->vatCalculator->calculatePriceWithSalesTax(netPrice: $netPrice); - $this->assertEquals($expectedGrossPrice->getPrice(), $grossPrice->getPrice()); + $this->assertEquals(expected: $expectedGrossPrice->getPrice(), actual: $grossPrice->getPrice()); } /** @@ -46,17 +46,17 @@ public function canCalculatePriceWithSalesTax(Price $netPrice, Price $expectedGr */ public static function dataProviderCanCalculatePriceWithSalesTax(): array { - $firstTestCase = Price::create(1200); // 12,00 € + $firstTestCase = Price::create(price: 1200); // 12,00 € - $expectedFirstGrossPrice = Price::create(1428); // 14,28 € + $expectedFirstGrossPrice = Price::create(price: 1428); // 14,28 € - $secondTestCase = Price::create(10599); // 105,99 € + $secondTestCase = Price::create(price: 10599); // 105,99 € - $expectedSecondGrossPrice = Price::create(12613); // 126,13 € + $expectedSecondGrossPrice = Price::create(price: 12613); // 126,13 € - $thirdTestCase = Price::create(411); // 4,11 € + $thirdTestCase = Price::create(price: 411); // 4,11 € - $expectedThirdGrossPrice = Price::create(489); // 4,89 € + $expectedThirdGrossPrice = Price::create(price: 489); // 4,89 € return [ [ @@ -78,9 +78,9 @@ public static function dataProviderCanCalculatePriceWithSalesTax(): array #[DataProvider(methodName: 'dataProviderCanCalculateSalesTaxFromTotalPrice')] public function canCalculateSalesTaxFromTotalPrice(Price $total, Price $expectedSalesTax): void { - $salesTax = $this->vatCalculator->calculateSalesTaxFromTotalPrice($total); + $salesTax = $this->vatCalculator->calculateSalesTaxFromTotalPrice(total: $total); - $this->assertEquals($expectedSalesTax->getPrice(), $salesTax->getPrice()); + $this->assertEquals(expected: $expectedSalesTax->getPrice(), actual: $salesTax->getPrice()); } /** @@ -91,13 +91,13 @@ public function canCalculateSalesTaxFromTotalPrice(Price $total, Price $expected */ public static function dataProviderCanCalculateSalesTaxFromTotalPrice(): array { - $firstGrossPrice = Price::create(1428); // 14,28 € + $firstGrossPrice = Price::create(price: 1428); // 14,28 € - $salesTaxFromFirstGrossPrice = Price::create(228); // 2,28 € + $salesTaxFromFirstGrossPrice = Price::create(price: 228); // 2,28 € - $secondGrossPrice = Price::create(12613); // 126,13 € + $secondGrossPrice = Price::create(price: 12613); // 126,13 € - $salesTaxFromSecondGrossPrice = Price::create(2014); // 20,14 € + $salesTaxFromSecondGrossPrice = Price::create(price: 2014); // 20,14 € return [ [ @@ -115,9 +115,9 @@ public static function dataProviderCanCalculateSalesTaxFromTotalPrice(): array #[DataProvider(methodName: 'dataProviderCanCalculateNetPriceFromGrossPrice')] public function canCalculateNetPriceFromGrossPrice(Price $total, Price $expectedNetPrice): void { - $netPrice = $this->vatCalculator->calculateNetPriceFromGrossPrice($total); + $netPrice = $this->vatCalculator->calculateNetPriceFromGrossPrice(total: $total); - $this->assertEquals($expectedNetPrice->getPrice(), $netPrice->getPrice()); + $this->assertEquals(expected: $expectedNetPrice->getPrice(), actual: $netPrice->getPrice()); } /** @@ -128,13 +128,13 @@ public function canCalculateNetPriceFromGrossPrice(Price $total, Price $expected */ public static function dataProviderCanCalculateNetPriceFromGrossPrice(): array { - $firstTestCase = Price::create(1428); // 14,28 € + $firstTestCase = Price::create(price: 1428); // 14,28 € - $expectedFirstNetPrice = Price::create(1200); // 12,00 € + $expectedFirstNetPrice = Price::create(price: 1200); // 12,00 € - $secondTestCase = Price::create(12613); // 126,13 € + $secondTestCase = Price::create(price: 12613); // 126,13 € - $expectedSecondNetPrice = Price::create(10599); // 105,99 € + $expectedSecondNetPrice = Price::create(price: 10599); // 105,99 € return [ [ diff --git a/tests/Helpers/Converter/Currencies/CentToEuroTest.php b/tests/Helpers/Converter/Currencies/CentToEuroTest.php index be074ea..fdd7739 100644 --- a/tests/Helpers/Converter/Currencies/CentToEuroTest.php +++ b/tests/Helpers/Converter/Currencies/CentToEuroTest.php @@ -21,8 +21,8 @@ final class CentToEuroTest extends TestCase public function hasImplemented(): void { $converter = new CentToEuro(); - $this->assertInstanceOf(ConverterInterface::class, $converter); - $this->assertInstanceOf(CentToEuro::class, $converter); + $this->assertInstanceOf(expected: ConverterInterface::class, actual: $converter); + $this->assertInstanceOf(expected: CentToEuro::class, actual: $converter); } #[Test] @@ -31,7 +31,7 @@ public function testConvert(float $amount, float $expected): void { $converter = new CentToEuro(); - $this->assertSame($expected, $converter->convert($amount)); + $this->assertSame(expected: $expected, actual: $converter->convert(amount: $amount)); } /** @@ -45,10 +45,22 @@ public function testConvert(float $amount, float $expected): void public static function dataProviderConvert(): array { return [ - [100.00, 1.00], - [250.00, 2.50], - [178, 1.78], - [.00, 0], + [ + 100.00, + 1.00, + ], + [ + 250.00, + 2.50, + ], + [ + 178, + 1.78, + ], + [ + .00, + 0, + ], ]; } } diff --git a/tests/Helpers/Converter/Currencies/EuroToCentTest.php b/tests/Helpers/Converter/Currencies/EuroToCentTest.php index d0232db..24876ec 100644 --- a/tests/Helpers/Converter/Currencies/EuroToCentTest.php +++ b/tests/Helpers/Converter/Currencies/EuroToCentTest.php @@ -21,8 +21,8 @@ final class EuroToCentTest extends TestCase public function hasImplemented(): void { $converter = new EuroToCent(); - $this->assertInstanceOf(ConverterInterface::class, $converter); - $this->assertInstanceOf(EuroToCent::class, $converter); + $this->assertInstanceOf(expected: ConverterInterface::class, actual: $converter); + $this->assertInstanceOf(expected: EuroToCent::class, actual: $converter); } #[Test] @@ -31,7 +31,7 @@ public function canConvert(float $amount, ?float $expected): void { $converter = new EuroToCent(); - $this->assertSame($expected, $converter->convert($amount)); + $this->assertSame(expected: $expected, actual: $converter->convert(amount: $amount)); } /** @@ -45,10 +45,22 @@ public function canConvert(float $amount, ?float $expected): void public static function dataProviderConvert(): array { return [ - [1.00, 100.00], - [1.15, 115.00], - [116.80, 11680.00], - [.00, 0], + [ + 1.00, + 100.00, + ], + [ + 1.15, + 115.00, + ], + [ + 116.80, + 11680.00, + ], + [ + .00, + 0, + ], ]; } } diff --git a/tests/Helpers/Entity/DiscountTest.php b/tests/Helpers/Entity/DiscountTest.php index afe8f8a..7bc2625 100644 --- a/tests/Helpers/Entity/DiscountTest.php +++ b/tests/Helpers/Entity/DiscountTest.php @@ -37,7 +37,8 @@ public static function dataProviderCreateDiscount(): array { return [ 'create_discount_successfully' => [ - 100, 100, + 100, + 100, ], ]; @@ -65,10 +66,12 @@ public static function dataProviderCannotCreateDiscount(): array { return [ 'failed_by_string' => [ - 'hello', true, + 'hello', + true, ], 'failed_by_object' => [ - new stdClass(), true, + new stdClass(), + true, ], ]; } diff --git a/tests/Helpers/View/PriceFormatterTest.php b/tests/Helpers/View/PriceFormatterTest.php index bd8f047..8ac770b 100644 --- a/tests/Helpers/View/PriceFormatterTest.php +++ b/tests/Helpers/View/PriceFormatterTest.php @@ -83,16 +83,36 @@ public static function dataProviderFormatPriceWithNoDefaults(): array { return [ [ - 1.15, '1 @', 0, '', '', '@', + 1.15, + '1 @', + 0, + '', + '', + '@', ], [ - 1000.15, '1/000|15 $', 2, '|', '/', '$', + 1000.15, + '1/000|15 $', + 2, + '|', + '/', + '$', ], [ - 1000.15, '1000,1500 XX', 4, ',', '', 'XX', + 1000.15, + '1000,1500 XX', + 4, + ',', + '', + 'XX', ], [ - 1000, '1,000 US-$', 0, '', ',', 'US-$', + 1000, + '1,000 US-$', + 0, + '', + ',', + 'US-$', ], ]; } @@ -109,16 +129,36 @@ public static function dataProviderFormatPriceForView(): array { return [ [ - 1.15, '1,15 €', 2, ',', '.', '€', + 1.15, + '1,15 €', + 2, + ',', + '.', + '€', ], [ - 4.05, '4,05 €', 2, ',', '.', '€', + 4.05, + '4,05 €', + 2, + ',', + '.', + '€', ], [ - .15, '0,15 €', 2, ',', '.', '€', + .15, + '0,15 €', + 2, + ',', + '.', + '€', ], [ - 761.60, '761,60 €', 2, ',', '.', '€', + 761.60, + '761,60 €', + 2, + ',', + '.', + '€', ], ]; } diff --git a/tests/PriceCalculatorTest.php b/tests/PriceCalculatorTest.php index 92cfe45..0f52992 100644 --- a/tests/PriceCalculatorTest.php +++ b/tests/PriceCalculatorTest.php @@ -29,16 +29,17 @@ private function getPriceCalculator(): PriceCalculator public function canInitPriceCalculator(): void { $priceCalculator = $this->getPriceCalculator(); - $this->assertInstanceOf(PriceCalculator::class, $priceCalculator); - $this->assertInstanceOf(PriceCalculatorInterface::class, $priceCalculator); + + $this->assertInstanceOf(expected: PriceCalculator::class, actual: $priceCalculator); + $this->assertInstanceOf(expected: PriceCalculatorInterface::class, actual: $priceCalculator); } #[Test] #[DataProvider(methodName: 'dataProviderAddPrice')] public function canAdd(Price $price, Price $amount, Price $expected): void { - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->addPrice($price, $amount); + $calculatedPrice = $this->getPriceCalculator()->addPrice($price, $amount); + $this->assertSame($expected->getPrice(), $calculatedPrice->getPrice()); } @@ -50,24 +51,28 @@ public function canAdd(Price $price, Price $amount, Price $expected): void */ public static function dataProviderAddPrice(): array { - $price = Price::create(100); + $price = Price::create(price: 100); - $amount = Price::create(200); + $amount = Price::create(price: 200); - $expectedPrice = Price::create(300); + $expectedPrice = Price::create(price: 300); - $priceUnderHundred = Price::create(13); + $priceUnderHundred = Price::create(price: 13); - $amountUnderHundred = Price::create(2); + $amountUnderHundred = Price::create(price: 2); - $expectedPriceUnderHundred = Price::create(15); + $expectedPriceUnderHundred = Price::create(price: 15); return [ 'add_price_about_hundred' => [ - $price, $amount, $expectedPrice, + $price, + $amount, + $expectedPrice, ], 'add_price_under_hundred' => [ - $priceUnderHundred, $amountUnderHundred, $expectedPriceUnderHundred, + $priceUnderHundred, + $amountUnderHundred, + $expectedPriceUnderHundred, ], ]; } @@ -76,10 +81,9 @@ public static function dataProviderAddPrice(): array #[DataProvider(methodName: 'dataProviderSubPrice')] public function canSub(Price $price, Price $amount, Price $total): void { - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->subPrice($price, $amount); + $calculatedPrice = $this->getPriceCalculator()->subPrice(total: $price, price: $amount); - $this->assertSame($total->getPrice(), $calculatedPrice->getPrice()); + $this->assertSame(expected: $total->getPrice(), actual: $calculatedPrice->getPrice()); } /** @@ -91,33 +95,39 @@ public function canSub(Price $price, Price $amount, Price $total): void */ public static function dataProviderSubPrice(): array { - $price = Price::create(300); + $price = Price::create(price: 300); - $amount = Price::create(200); + $amount = Price::create(price: 200); - $expectedPrice = Price::create(100); + $expectedPrice = Price::create(price: 100); - $priceUnderHundred = Price::create(15); + $priceUnderHundred = Price::create(price: 15); - $amountUnderHundred = Price::create(2); + $amountUnderHundred = Price::create(price: 2); - $expectedPriceUnderHundred = Price::create(13); + $expectedPriceUnderHundred = Price::create(price: 13); - $priceForZeroResult = Price::create(5); + $priceForZeroResult = Price::create(price: 5); - $amountForZeroResult = Price::create(6); + $amountForZeroResult = Price::create(price: 6); - $expectedPriceForZeroResult = Price::create(0); + $expectedPriceForZeroResult = Price::create(price: 0); return [ - 'sub_price_about_hundred' => [ - $price, $amount, $expectedPrice, + 'sub_price_about_hundred' => [ + $price, + $amount, + $expectedPrice, ], - 'sub_price_under_hundred' => [ - $priceUnderHundred, $amountUnderHundred, $expectedPriceUnderHundred, + 'sub_price_under_hundred' => [ + $priceUnderHundred, + $amountUnderHundred, + $expectedPriceUnderHundred, ], 'sub_price_and_calculate_zero_price' => [ - $priceForZeroResult, $amountForZeroResult, $expectedPriceForZeroResult, + $priceForZeroResult, + $amountForZeroResult, + $expectedPriceForZeroResult, ], ]; } @@ -126,10 +136,9 @@ public static function dataProviderSubPrice(): array #[DataProvider(methodName: 'dataProviderMulPrice')] public function canMul(Price $price, Price $amount, Price $total): void { - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->mulPrice($amount, $price); + $calculatedPrice = $this->getPriceCalculator()->mulPrice(amount: $amount, price: $price); - $this->assertEquals($total->getPrice(), $calculatedPrice->getPrice()); + $this->assertEquals(expected: $total->getPrice(), actual: $calculatedPrice->getPrice()); } /** @@ -140,24 +149,28 @@ public function canMul(Price $price, Price $amount, Price $total): void */ public static function dataProviderMulPrice(): array { - $priceWithBigNumber = Price::create(100); + $priceWithBigNumber = Price::create(price: 100); - $amountForMulWithBigNumber = Price::create(5); + $amountForMulWithBigNumber = Price::create(price: 5); - $expectedPriceWithBigNumber = Price::create(500); + $expectedPriceWithBigNumber = Price::create(price: 500); - $priceWithLowNumbers = Price::create(15); + $priceWithLowNumbers = Price::create(price: 15); - $amountForMulWithLowNumbers = Price::create(2); + $amountForMulWithLowNumbers = Price::create(price: 2); - $expectedPriceWithLowNumbers = Price::create(30); + $expectedPriceWithLowNumbers = Price::create(price: 30); return [ 'mul_with_big_numbers' => [ - $priceWithBigNumber, $amountForMulWithBigNumber, $expectedPriceWithBigNumber, + $priceWithBigNumber, + $amountForMulWithBigNumber, + $expectedPriceWithBigNumber, ], 'mul_with_low_numbers' => [ - $priceWithLowNumbers, $amountForMulWithLowNumbers, $expectedPriceWithLowNumbers, + $priceWithLowNumbers, + $amountForMulWithLowNumbers, + $expectedPriceWithLowNumbers, ], ]; } @@ -166,10 +179,9 @@ public static function dataProviderMulPrice(): array #[DataProvider(methodName: 'dataProviderDivPrice')] public function canDiv(Price $price, int $amount, Price $total): void { - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->divPrice($amount, $price); + $calculatedPrice = $this->getPriceCalculator()->divPrice(amount: $amount, price: $price); - $this->assertEquals($total->getPrice(), $calculatedPrice->getPrice()); + $this->assertEquals(expected: $total->getPrice(), actual: $calculatedPrice->getPrice()); } /** @@ -180,30 +192,36 @@ public function canDiv(Price $price, int $amount, Price $total): void */ public static function dataProviderDivPrice(): array { - $priceWithBigNumber = Price::create(500); + $priceWithBigNumber = Price::create(price: 500); $amountForMulWithBigNumber = 5; - $expectedPriceWithBigNumber = Price::create(100); + $expectedPriceWithBigNumber = Price::create(price: 100); - $priceWithLowNumbers = Price::create(30); + $priceWithLowNumbers = Price::create(price: 30); $amountForMulWithLowNumbers = 2; - $expectedPriceWithLowNumbers = Price::create(15); + $expectedPriceWithLowNumbers = Price::create(price: 15); - $priceForZeroResult = Price::create(0); + $priceForZeroResult = Price::create(price: 0); $amountForZeroResult = 6; - $expectedPriceForZeroResult = Price::create(0); + $expectedPriceForZeroResult = Price::create(price: 0); return [ - 'div_with_big_numbers' => [ - $priceWithBigNumber, $amountForMulWithBigNumber, $expectedPriceWithBigNumber, + 'div_with_big_numbers' => [ + $priceWithBigNumber, + $amountForMulWithBigNumber, + $expectedPriceWithBigNumber, ], - 'div_with_low_numbers' => [ - $priceWithLowNumbers, $amountForMulWithLowNumbers, $expectedPriceWithLowNumbers, + 'div_with_low_numbers' => [ + $priceWithLowNumbers, + $amountForMulWithLowNumbers, + $expectedPriceWithLowNumbers, ], 'sub_price_and_calculate_zero_price' => [ - $priceForZeroResult, $amountForZeroResult, $expectedPriceForZeroResult, + $priceForZeroResult, + $amountForZeroResult, + $expectedPriceForZeroResult, ], ]; } @@ -211,46 +229,42 @@ public static function dataProviderDivPrice(): array #[Test] public function subResultCannotHaveNegativeAmount(): void { - $totalPrice = Price::create(200); - $sub = Price::create(300); + $totalPrice = Price::create(price: 200); + $sub = Price::create(price: 300); - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->subPrice($totalPrice, $sub); + $calculatedPrice = $this->getPriceCalculator()->subPrice(total: $totalPrice, price: $sub); - $this->assertSame(0, $calculatedPrice->getPrice()); + $this->assertSame(expected: 0, actual: $calculatedPrice->getPrice()); } #[Test] public function subResultCannotHaveZeroAmount(): void { - $totalPrice = Price::create(200); - $sub = Price::create(200); + $totalPrice = Price::create(price: 200); + $sub = Price::create(price: 200); - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->subPrice($totalPrice, $sub); + $calculatedPrice = $this->getPriceCalculator()->subPrice(total: $totalPrice, price: $sub); - $this->assertSame(0, $calculatedPrice->getPrice()); + $this->assertSame(expected: 0, actual: $calculatedPrice->getPrice()); } #[Test] public function divResultCannotHaveZeroAmount(): void { - $totalPrice = Price::create(200); + $totalPrice = Price::create(price: 200); - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->divPrice(0, $totalPrice); + $calculatedPrice = $this->getPriceCalculator()->divPrice(amount: 0, price: $totalPrice); - $this->assertSame(0, $calculatedPrice->getPrice()); + $this->assertSame(expected: 0, actual: $calculatedPrice->getPrice()); } #[Test] public function divResultCannotHaveNegativeAmount(): void { - $totalPrice = Price::create(0); + $totalPrice = Price::create(price: 0); - $priceCalculator = $this->getPriceCalculator(); - $calculatedPrice = $priceCalculator->divPrice(-200, $totalPrice); + $calculatedPrice = $this->getPriceCalculator()->divPrice(amount: -200, price: $totalPrice); - $this->assertSame(0, $calculatedPrice->getPrice()); + $this->assertSame(expected: 0, actual: $calculatedPrice->getPrice()); } } diff --git a/tests/Service/DiscountCalculatorTest.php b/tests/Service/DiscountCalculatorTest.php index 87577bf..15bc6c2 100644 --- a/tests/Service/DiscountCalculatorTest.php +++ b/tests/Service/DiscountCalculatorTest.php @@ -25,11 +25,12 @@ final class DiscountCalculatorTest extends TestCase #[DataProvider(methodName: 'dataProviderCalculateDiscountPriceFromTotal')] public function canCalculateDiscountPriceFromTotal(Price $total, Discount $percent, Price $expectedPrice): void { - $discountCalculator = new DiscountCalculator(); + $calculatedPrice = (new DiscountCalculator())->calculateDiscountPriceFromTotal( + total: $total, + discount: $percent + ); - $calculatedPrice = $discountCalculator->calculateDiscountPriceFromTotal($total, $percent); - - $this->assertSame($expectedPrice->getPrice(), $calculatedPrice->getPrice()); + $this->assertSame(expected: $expectedPrice->getPrice(), actual: $calculatedPrice->getPrice()); } /** @@ -40,21 +41,25 @@ public function canCalculateDiscountPriceFromTotal(Price $total, Discount $perce */ public static function dataProviderCalculateDiscountPriceFromTotal(): array { - $discount = new Discount(45); - $totalPrice = Price::create(100); + $discount = new Discount(percent: 45); + $totalPrice = Price::create(price: 100); - $expectedDiscountPrice = Price::create(45); + $expectedDiscountPrice = Price::create(price: 45); - $totalPriceIsZero = Price::create(0); + $totalPriceIsZero = Price::create(price: 0); - $expectedDiscountPriceIsZero = Price::create(0); + $expectedDiscountPriceIsZero = Price::create(price: 0); return [ - 'can_calculate_discount' => [ - $totalPrice, $discount, $expectedDiscountPrice, + 'can_calculate_discount' => [ + $totalPrice, + $discount, + $expectedDiscountPrice, ], 'can_handle_if_price_is_zero' => [ - $totalPriceIsZero, $discount, $expectedDiscountPriceIsZero, + $totalPriceIsZero, + $discount, + $expectedDiscountPriceIsZero, ], ]; } @@ -63,11 +68,12 @@ public static function dataProviderCalculateDiscountPriceFromTotal(): array #[DataProvider(methodName: 'dataProviderCalculateDiscountFromTotal')] public function canCalculateDiscountFromTotal(Price $total, Discount $percent, Price $expectedPrice): void { - $discountCalculator = new DiscountCalculator(); - - $calculatedPrice = $discountCalculator->calculateDiscountFromTotal($total, $percent); + $calculatedPrice = (new DiscountCalculator())->calculateDiscountFromTotal( + total: $total, + discount: $percent + ); - $this->assertSame($expectedPrice->getPrice(), $calculatedPrice->getPrice()); + $this->assertSame(expected: $expectedPrice->getPrice(), actual: $calculatedPrice->getPrice()); } /** @@ -78,22 +84,26 @@ public function canCalculateDiscountFromTotal(Price $total, Discount $percent, P */ public static function dataProviderCalculateDiscountFromTotal(): array { - $discount = new Discount(45); - $totalPrice = Price::create(100); + $discount = new Discount(percent: 45); + $totalPrice = Price::create(price: 100); - $expectedDiscountPrice = Price::create(55); + $expectedDiscountPrice = Price::create(price: 55); - $discountForZeroTotalPrice = new Discount(30); - $totalPriceForZeroTotalPrice = Price::create(0); + $discountForZeroTotalPrice = new Discount(percent: 30); + $totalPriceForZeroTotalPrice = Price::create(price: 0); - $expectedDiscountPriceForZeroTest = Price::create(0); + $expectedDiscountPriceForZeroTest = Price::create(price: 0); return [ - 'can_calculate_total_price_after_discount' => [ - $totalPrice, $discount, $expectedDiscountPrice, + 'can_calculate_total_price_after_discount' => [ + $totalPrice, + $discount, + $expectedDiscountPrice, ], 'can_handle_zero_total_price_without_error' => [ - $totalPriceForZeroTotalPrice, $discountForZeroTotalPrice, $expectedDiscountPriceForZeroTest, + $totalPriceForZeroTotalPrice, + $discountForZeroTotalPrice, + $expectedDiscountPriceForZeroTest, ], ]; } diff --git a/tests/Service/VatCalculatorTest.php b/tests/Service/VatCalculatorTest.php index 27a3491..89b36cf 100644 --- a/tests/Service/VatCalculatorTest.php +++ b/tests/Service/VatCalculatorTest.php @@ -26,8 +26,9 @@ final class VatCalculatorTest extends TestCase #[Test] public function canCreateVatCalculator(): void { - $vatCalculator = new VatCalculator(Vat::create(0), new PriceCalculator()); - $this->assertInstanceOf(VatCalculator::class, $vatCalculator); + $vatCalculator = new VatCalculator(vat: Vat::create(vat: 0), priceCalculator: new PriceCalculator()); + + $this->assertInstanceOf(expected: VatCalculator::class, actual: $vatCalculator); } #[Test] @@ -40,9 +41,9 @@ public function canCalculateSalesTaxOfTotal( ): void { $vatCalculator = new VatCalculator($vat, new PriceCalculator()); $vatPrice = $vatCalculator->calculateSalesTaxFromTotalPrice($grossPrice); - $this->assertSame($expectedVat->getPrice(), $vatPrice->getPrice()); - $this->assertSame($netPrice->getPrice(), $grossPrice->getPrice() - $vatPrice->getPrice()); - $this->assertSame($grossPrice->getPrice(), $netPrice->getPrice() + $vatPrice->getPrice()); + $this->assertSame(expected: $expectedVat->getPrice(), actual: $vatPrice->getPrice()); + $this->assertSame(expected: $netPrice->getPrice(), actual: $grossPrice->getPrice() - $vatPrice->getPrice()); + $this->assertSame(expected: $grossPrice->getPrice(), actual: $netPrice->getPrice() + $vatPrice->getPrice()); } /** @@ -50,34 +51,43 @@ public function canCalculateSalesTaxOfTotal( */ public static function dataProviderSalesTaxOfTotal(): array { - $firstGrossPrice = Price::create(24); + $firstGrossPrice = Price::create(price: 24); - $vat = Vat::create(19); - $firstNetPrice = Price::create(20); + $vat = Vat::create(vat: 19); + $firstNetPrice = Price::create(price: 20); - $expectedVatPrice = Price::create(4); + $expectedVatPrice = Price::create(price: 4); - $secondGrossPrice = Price::create(30000); + $secondGrossPrice = Price::create(price: 30000); - $secondNetPrice = Price::create(25210); + $secondNetPrice = Price::create(price: 25210); - $expectedSecondVatPrice = Price::create(4790); + $expectedSecondVatPrice = Price::create(price: 4790); - $thirdGrossPrice = Price::create(1500); + $thirdGrossPrice = Price::create(price: 1500); - $thirdNetPrice = Price::create(1261); + $thirdNetPrice = Price::create(price: 1261); - $expectedThirdVatPrice = Price::create(239); + $expectedThirdVatPrice = Price::create(price: 239); return [ [ - $firstGrossPrice, $vat, $firstNetPrice, $expectedVatPrice, + $firstGrossPrice, + $vat, + $firstNetPrice, + $expectedVatPrice, ], [ - $secondGrossPrice, $vat, $secondNetPrice, $expectedSecondVatPrice, + $secondGrossPrice, + $vat, + $secondNetPrice, + $expectedSecondVatPrice, ], [ - $thirdGrossPrice, $vat, $thirdNetPrice, $expectedThirdVatPrice, + $thirdGrossPrice, + $vat, + $thirdNetPrice, + $expectedThirdVatPrice, ], ]; } @@ -86,11 +96,11 @@ public static function dataProviderSalesTaxOfTotal(): array #[DataProvider(methodName: 'dataProviderPriceWithSalesTax')] public function canCalculatePriceWithSalesTax(Price $netPrice, Vat $vat, Price $expectedPrice): void { - $vatCalculator = new VatCalculator($vat, new PriceCalculator()); + $vatCalculator = new VatCalculator(vat: $vat, priceCalculator: new PriceCalculator()); - $calculatedPrice = $vatCalculator->calculatePriceWithSalesTax($netPrice); + $calculatedPrice = $vatCalculator->calculatePriceWithSalesTax(netPrice: $netPrice); - $this->assertSame($expectedPrice->getPrice(), $calculatedPrice->getPrice()); + $this->assertSame(expected: $expectedPrice->getPrice(), actual: $calculatedPrice->getPrice()); } /** @@ -98,27 +108,33 @@ public function canCalculatePriceWithSalesTax(Price $netPrice, Vat $vat, Price $ */ public static function dataProviderPriceWithSalesTax(): array { - $lowPrice = Price::create(3151); - $vat = Vat::create(19); - $expectedLowPrice = Price::create(3750); + $lowPrice = Price::create(price: 3151); + $vat = Vat::create(vat: 19); + $expectedLowPrice = Price::create(price: 3750); - $secondPrice = Price::create(25200); + $secondPrice = Price::create(price: 25200); - $expectedSecondPrice = Price::create(29988); + $expectedSecondPrice = Price::create(price: 29988); - $thirdPrice = Price::create(15); + $thirdPrice = Price::create(price: 15); - $expectedThirdPrice = Price::create(18); + $expectedThirdPrice = Price::create(price: 18); return [ [ - $lowPrice, $vat, $expectedLowPrice, + $lowPrice, + $vat, + $expectedLowPrice, ], [ - $secondPrice, $vat, $expectedSecondPrice, + $secondPrice, + $vat, + $expectedSecondPrice, ], [ - $thirdPrice, $vat, $expectedThirdPrice, + $thirdPrice, + $vat, + $expectedThirdPrice, ], ]; } @@ -127,10 +143,10 @@ public static function dataProviderPriceWithSalesTax(): array #[DataProvider(methodName: 'dataProviderCalculateNetPriceFromGrossPrice')] public function canCalculateNetPriceFromGrossPrice(Price $grossPrice, Vat $vat, Price $expectedNetPrice): void { - $vatCalculator = new VatCalculator($vat, new PriceCalculator()); - $netPrice = $vatCalculator->calculateNetPriceFromGrossPrice($grossPrice); + $vatCalculator = new VatCalculator(vat: $vat, priceCalculator: new PriceCalculator()); + $netPrice = $vatCalculator->calculateNetPriceFromGrossPrice(total: $grossPrice); - $this->assertSame($expectedNetPrice->getPrice(), $netPrice->getPrice()); + $this->assertSame(expected: $expectedNetPrice->getPrice(), actual: $netPrice->getPrice()); } /** @@ -138,28 +154,34 @@ public function canCalculateNetPriceFromGrossPrice(Price $grossPrice, Vat $vat, */ public static function dataProviderCalculateNetPriceFromGrossPrice(): array { - $lowPrice = Price::create(3750); - $vat = Vat::create(19); + $lowPrice = Price::create(price: 3750); + $vat = Vat::create(vat: 19); - $expectedLowPrice = Price::create(3151); + $expectedLowPrice = Price::create(price: 3151); - $secondPrice = Price::create(29988); + $secondPrice = Price::create(price: 29988); - $expectedSecondPrice = Price::create(25200); + $expectedSecondPrice = Price::create(price: 25200); - $thirdPrice = Price::create(18); + $thirdPrice = Price::create(price: 18); - $expectedThirdPrice = Price::create(15); + $expectedThirdPrice = Price::create(price: 15); return [ [ - $lowPrice, $vat, $expectedLowPrice, + $lowPrice, + $vat, + $expectedLowPrice, ], [ - $secondPrice, $vat, $expectedSecondPrice, + $secondPrice, + $vat, + $expectedSecondPrice, ], [ - $thirdPrice, $vat, $expectedThirdPrice, + $thirdPrice, + $vat, + $expectedThirdPrice, ], ]; } diff --git a/tests/UnitConverterTest.php b/tests/UnitConverterTest.php index 5f9283f..14b37b4 100644 --- a/tests/UnitConverterTest.php +++ b/tests/UnitConverterTest.php @@ -24,9 +24,10 @@ final class UnitConverterTest extends TestCase #[Test] public function hasImplemented(): void { - $unitConverter = new UnitConverter(new Converter()); - $this->assertInstanceOf(UnitConverterInterface::class, $unitConverter); - $this->assertInstanceOf(UnitConverter::class, $unitConverter); + $unitConverter = new UnitConverter(factory: new Converter()); + + $this->assertInstanceOf(expected: UnitConverterInterface::class, actual: $unitConverter); + $this->assertInstanceOf(expected: UnitConverter::class, actual: $unitConverter); } #[Test] @@ -34,10 +35,10 @@ public function canConvert(): void { $unitConverter = new UnitConverter(new Converter()); - $converter = $unitConverter->convert(ConverterFactoryInterface::EURO_TO_CENT); - $this->assertInstanceOf(ConverterInterface::class, $converter); + $converter = $unitConverter->convert(destinationUnit: ConverterFactoryInterface::EURO_TO_CENT); + $this->assertInstanceOf(expected: ConverterInterface::class, actual: $converter); - $converter = $unitConverter->convert(ConverterFactoryInterface::CENT_TO_EURO); - $this->assertInstanceOf(ConverterInterface::class, $converter); + $converter = $unitConverter->convert(destinationUnit: ConverterFactoryInterface::CENT_TO_EURO); + $this->assertInstanceOf(expected: ConverterInterface::class, actual: $converter); } } From ed71f46dc32ac27ec39a8402d78577f20f804d65 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 13:32:19 +0200 Subject: [PATCH 3/9] Fix workflow actions and update documentation Signed-off-by: Marcel Strahl --- .github/workflows/ci.yml | 3 +++ CHANGELOG.md | 6 ++++++ UPGRADE-6.0.md | 6 ++++++ readme.md | 13 ++++++++----- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 UPGRADE-6.0.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23dcdd3..d821649 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,6 +159,9 @@ jobs: - name: "Install dependencies" run: composer install --no-interaction + - name: "Generate PHPUnit coverage for Infection" + run: composer test + - name: "Run infection (with badge upload)" if: matrix.php == '8.3' env: diff --git a/CHANGELOG.md b/CHANGELOG.md index e46b052..ae509c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ This Changelog refers to all changes since v5.0.0 *** +# v6.0.0 ++ Upgrade of dependencies, removed PHP 8.0 support. ++ Modernize code ++ Adding PHP mess detector ++ Restructure GitHub workflow actions. + # v5.0.1 + Upgrade of dependencies, removal of PHPStan as I focused more on Psalm. + All test classes are now final and use attributes instead of annotations. diff --git a/UPGRADE-6.0.md b/UPGRADE-6.0.md new file mode 100644 index 0000000..6a2a8fd --- /dev/null +++ b/UPGRADE-6.0.md @@ -0,0 +1,6 @@ +# UPGRADE FROM 5.x to 6.0 + +### Breaking Changes: + ++ Support for PHP 8.0 removed. Only PHP 8.1, 8.2, 8.3, and 8.4 are supported. ++ This library now uses named arguments. diff --git a/readme.md b/readme.md index 48e6f4e..8350204 100644 --- a/readme.md +++ b/readme.md @@ -22,12 +22,15 @@ You are also welcome to use the Issue Tracker to set bugs, improvements or upgra ```bash composer require marcel-strahl/price-calculator ``` + ### Supported PHP Versions -| PHP | Package Version | Status | -|:-----:|:---------------:|:-------------:| -| ^8.0 | v5.x.x | Support | -| ^7.4 | v4.x.x | Not supported | -| <^7.4 | <=v3.x.x | Not supported | + +| PHP | Package Version | Status | +|:------:|:---------------:|:-------------:| +| >=^8.1 | v6.x.x | Supported | +| <=^8.0 | v5.0.1 | Not supported | +| ^7.4 | v4.x.x | Not supported | +| <^7.4 | <=v3.x.x | Not supported | ### Documentation From 274f5a44df06fc6431396482238d9ad3b01c9bf4 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 14:07:41 +0200 Subject: [PATCH 4/9] Fixing psalm on php 8.4 Signed-off-by: Marcel Strahl --- composer.json | 6 +++--- psalm.xml | 4 ++++ src/Exceptions/PriceCalculatorFactoryException.php | 6 +++--- src/Facade/PriceCalculator.php | 2 +- src/Facade/UnitConverter.php | 2 +- src/Facade/VatCalculator.php | 2 +- src/Factory/Converter.php | 2 +- src/Helpers/Converter/Currencies/CentToEuro.php | 2 +- src/Helpers/Converter/Currencies/EuroToCent.php | 2 +- src/Helpers/Entity/Discount.php | 2 +- src/Helpers/Entity/Price.php | 2 +- src/Helpers/Entity/Vat.php | 2 +- src/Helpers/View/PriceFormatter.php | 2 +- src/PriceCalculator.php | 2 +- src/Service/DiscountCalculator.php | 2 +- src/Service/VatCalculator.php | 2 +- src/UnitConverter.php | 2 +- 17 files changed, 24 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 2fc754d..472e4fe 100644 --- a/composer.json +++ b/composer.json @@ -17,12 +17,12 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.87", - "infection/infection": "^0.27", + "infection/infection": "^0.27|^0.29", "phpstan/extension-installer": "*", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^10.5|^11.5", "psalm/plugin-phpunit": "^0.19", "phpmd/phpmd": "^2.15", - "vimeo/psalm": "^5.26" + "vimeo/psalm": "^5.26|^6.0" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml index 6d8258b..4c43013 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,6 +14,10 @@ + + + + diff --git a/src/Exceptions/PriceCalculatorFactoryException.php b/src/Exceptions/PriceCalculatorFactoryException.php index dd90214..7a059b2 100644 --- a/src/Exceptions/PriceCalculatorFactoryException.php +++ b/src/Exceptions/PriceCalculatorFactoryException.php @@ -11,15 +11,15 @@ /** * @author Marcel Strahl */ -class PriceCalculatorFactoryException extends InvalidArgumentException +final class PriceCalculatorFactoryException extends InvalidArgumentException { private const MESSAGE = 'The required currency translation is not currently supported. Type: %s'; public static function fromUnsupportedArgument(string $type): self { return new self( - sprintf(self::MESSAGE, $type), - 500 + message: sprintf(self::MESSAGE, $type), + code: 500 ); } } diff --git a/src/Facade/PriceCalculator.php b/src/Facade/PriceCalculator.php index acd13e8..9e0d3b9 100644 --- a/src/Facade/PriceCalculator.php +++ b/src/Facade/PriceCalculator.php @@ -10,7 +10,7 @@ /** * @author Marcel Strahl */ -class PriceCalculator +final class PriceCalculator { public static function getPriceCalculator(): PriceCalculatorInterface { diff --git a/src/Facade/UnitConverter.php b/src/Facade/UnitConverter.php index d5d92c0..13293d0 100644 --- a/src/Facade/UnitConverter.php +++ b/src/Facade/UnitConverter.php @@ -10,7 +10,7 @@ /** * @author Marcel Strahl */ -class UnitConverter +final class UnitConverter { /** * @return UnitConverterService diff --git a/src/Facade/VatCalculator.php b/src/Facade/VatCalculator.php index 2d29c05..2647c16 100644 --- a/src/Facade/VatCalculator.php +++ b/src/Facade/VatCalculator.php @@ -11,7 +11,7 @@ /** * @author Marcel Strahl */ -class VatCalculator +final class VatCalculator { private function __construct(private Vat $vat, private PriceCalculatorInterface $priceCalculator) { diff --git a/src/Factory/Converter.php b/src/Factory/Converter.php index c43bac0..3f02689 100644 --- a/src/Factory/Converter.php +++ b/src/Factory/Converter.php @@ -13,7 +13,7 @@ /** * @author Marcel Strahl */ -class Converter implements ConverterFactoryInterface +final class Converter implements ConverterFactoryInterface { /** * {@inheritDoc} diff --git a/src/Helpers/Converter/Currencies/CentToEuro.php b/src/Helpers/Converter/Currencies/CentToEuro.php index ce570da..1bdd94e 100644 --- a/src/Helpers/Converter/Currencies/CentToEuro.php +++ b/src/Helpers/Converter/Currencies/CentToEuro.php @@ -10,7 +10,7 @@ /** * @author Marcel Strahl */ -class CentToEuro implements ConverterInterface +final class CentToEuro implements ConverterInterface { /** * {@inheritdoc} diff --git a/src/Helpers/Converter/Currencies/EuroToCent.php b/src/Helpers/Converter/Currencies/EuroToCent.php index df404f1..9791a48 100644 --- a/src/Helpers/Converter/Currencies/EuroToCent.php +++ b/src/Helpers/Converter/Currencies/EuroToCent.php @@ -10,7 +10,7 @@ /** * @author Marcel Strahl */ -class EuroToCent implements ConverterInterface +final class EuroToCent implements ConverterInterface { /** * {@inheritdoc} diff --git a/src/Helpers/Entity/Discount.php b/src/Helpers/Entity/Discount.php index 6cd033b..f70a81f 100644 --- a/src/Helpers/Entity/Discount.php +++ b/src/Helpers/Entity/Discount.php @@ -8,7 +8,7 @@ /** * @author Marcel Strahl */ -class Discount implements DiscountInterface +final class Discount implements DiscountInterface { private float $percent; diff --git a/src/Helpers/Entity/Price.php b/src/Helpers/Entity/Price.php index 96b68da..21398a0 100644 --- a/src/Helpers/Entity/Price.php +++ b/src/Helpers/Entity/Price.php @@ -7,7 +7,7 @@ /** * @author Marcel Strahl */ -class Price +final class Price { private function __construct(private int $price) { diff --git a/src/Helpers/Entity/Vat.php b/src/Helpers/Entity/Vat.php index ca3ff98..afbedad 100644 --- a/src/Helpers/Entity/Vat.php +++ b/src/Helpers/Entity/Vat.php @@ -9,7 +9,7 @@ /** * @author Marcel Strahl */ -class Vat implements VatInterface +final class Vat implements VatInterface { private function __construct(private int $vat) { diff --git a/src/Helpers/View/PriceFormatter.php b/src/Helpers/View/PriceFormatter.php index a091b78..bf476d0 100644 --- a/src/Helpers/View/PriceFormatter.php +++ b/src/Helpers/View/PriceFormatter.php @@ -9,7 +9,7 @@ /** * @author Marcel Strahl */ -class PriceFormatter implements Formatter +final class PriceFormatter implements Formatter { /** * @var int diff --git a/src/PriceCalculator.php b/src/PriceCalculator.php index 95e24ed..cf3217d 100644 --- a/src/PriceCalculator.php +++ b/src/PriceCalculator.php @@ -11,7 +11,7 @@ /** * @author Marcel Strahl */ -class PriceCalculator implements PriceCalculatorInterface +final class PriceCalculator implements PriceCalculatorInterface { /** * {@inheritdoc} diff --git a/src/Service/DiscountCalculator.php b/src/Service/DiscountCalculator.php index fd62972..db5bad6 100644 --- a/src/Service/DiscountCalculator.php +++ b/src/Service/DiscountCalculator.php @@ -15,7 +15,7 @@ /** * @author Marcel Strahl */ -class DiscountCalculator implements DiscountCalculatorInterface +final class DiscountCalculator implements DiscountCalculatorInterface { private const NEEDLE_FLOAT_SEPARATOR = '.'; diff --git a/src/Service/VatCalculator.php b/src/Service/VatCalculator.php index 70cf68e..8d1c976 100644 --- a/src/Service/VatCalculator.php +++ b/src/Service/VatCalculator.php @@ -14,7 +14,7 @@ /** * @author Marcel Strahl */ -class VatCalculator implements VatCalculatorInterface +final class VatCalculator implements VatCalculatorInterface { private Vat $vat; private PriceCalculatorInterface $priceCalculator; diff --git a/src/UnitConverter.php b/src/UnitConverter.php index 05ef7d5..42efb0a 100644 --- a/src/UnitConverter.php +++ b/src/UnitConverter.php @@ -11,7 +11,7 @@ /** * @author Marcel Strahl */ -class UnitConverter implements UnitConverterInterface +final class UnitConverter implements UnitConverterInterface { /** * @var ConverterFactoryInterface From 12940d351dafdf6428f3dd3c214ec62e274c1992 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 14:09:05 +0200 Subject: [PATCH 5/9] Add PHP 8.5 Signed-off-by: Marcel Strahl --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d821649..f196f0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.2', '8.3', '8.4' ] + php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ] steps: - name: "Checkout" uses: actions/checkout@v5 From 2b1b0e110dddc0b78fdb997d3fca84157ab72834 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 14:11:00 +0200 Subject: [PATCH 6/9] Add PHP 8.5 Signed-off-by: Marcel Strahl --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 472e4fe..3238a82 100644 --- a/composer.json +++ b/composer.json @@ -17,12 +17,12 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.87", - "infection/infection": "^0.27|^0.29", + "infection/infection": "^0.27|^0.29.14", "phpstan/extension-installer": "*", "phpunit/phpunit": "^10.5|^11.5", "psalm/plugin-phpunit": "^0.19", "phpmd/phpmd": "^2.15", - "vimeo/psalm": "^5.26|^6.0" + "vimeo/psalm": "^5.26|^6.0|^7.*" }, "autoload": { "psr-4": { From efc7e0021e5bbd33e0a14b38ac030cef6addac4c Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 14:11:17 +0200 Subject: [PATCH 7/9] Add PHP 8.5 Signed-off-by: Marcel Strahl --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3238a82..dfa57d5 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "friendsofphp/php-cs-fixer": "^3.87", "infection/infection": "^0.27|^0.29.14", "phpstan/extension-installer": "*", - "phpunit/phpunit": "^10.5|^11.5", + "phpunit/phpunit": "^10.5|^11.5|^12.3", "psalm/plugin-phpunit": "^0.19", "phpmd/phpmd": "^2.15", "vimeo/psalm": "^5.26|^6.0|^7.*" From 15a55c76e37ff74a6a85fb36afc571f392514ad6 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 14:12:03 +0200 Subject: [PATCH 8/9] Add PHP 8.5 Signed-off-by: Marcel Strahl --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dfa57d5..d05a7a1 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "phpunit/phpunit": "^10.5|^11.5|^12.3", "psalm/plugin-phpunit": "^0.19", "phpmd/phpmd": "^2.15", - "vimeo/psalm": "^5.26|^6.0|^7.*" + "vimeo/psalm": "^5.26|^6.0|7.*" }, "autoload": { "psr-4": { From d2ab7c09ef915c30873ccb9386e7d3145a3ca4a8 Mon Sep 17 00:00:00 2001 From: Marcel Strahl Date: Sat, 6 Sep 2025 14:14:14 +0200 Subject: [PATCH 9/9] Add PHP 8.5 Signed-off-by: Marcel Strahl --- .github/workflows/ci.yml | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f196f0e..d821649 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ] + php: [ '8.1', '8.2', '8.3', '8.4' ] steps: - name: "Checkout" uses: actions/checkout@v5 diff --git a/composer.json b/composer.json index d05a7a1..eee9737 100644 --- a/composer.json +++ b/composer.json @@ -19,10 +19,10 @@ "friendsofphp/php-cs-fixer": "^3.87", "infection/infection": "^0.27|^0.29.14", "phpstan/extension-installer": "*", - "phpunit/phpunit": "^10.5|^11.5|^12.3", + "phpunit/phpunit": "^10.5|^12.3", "psalm/plugin-phpunit": "^0.19", "phpmd/phpmd": "^2.15", - "vimeo/psalm": "^5.26|^6.0|7.*" + "vimeo/psalm": "^5.26|^6.0" }, "autoload": { "psr-4": {