1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 19:34:02 +00:00

Laravel 12 support (#28)

* Laravel 12 support

* bump larastan

* phpstan fixes

* remove pest()

* update larastan dependency name
This commit is contained in:
Samuel Štancl 2025-03-11 17:38:43 +01:00 committed by GitHub
parent b642e32a4b
commit f5011bce68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 18 deletions

View file

@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
laravel: [10, 11] laravel: [10, 11, 12]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View file

@ -25,15 +25,15 @@
}, },
"require": { "require": {
"php": "^8.2", "php": "^8.2",
"illuminate/support": "^10.0|^11.0", "illuminate/support": "^10.0|^11.0|^12.0",
"archtechx/helpers": "^0.3.2" "archtechx/helpers": "^0.3.2"
}, },
"require-dev": { "require-dev": {
"orchestra/testbench": "^8.0|^9.0", "orchestra/testbench": "^8.0|^9.0|^10.0",
"pestphp/pest": "^2.0", "pestphp/pest": "^2.0|^3.7",
"phpstan/phpstan": "^1.9.8", "phpstan/phpstan": "^1.9.8|^2.1",
"pestphp/pest-plugin-laravel": "^2.0", "pestphp/pest-plugin-laravel": "^2.0|^3.1",
"nunomaduro/larastan": "^2.4" "larastan/larastan": "^2.4|^3.0"
}, },
"extra": { "extra": {
"laravel": { "laravel": {

View file

@ -1,5 +1,5 @@
includes: includes:
- ./vendor/nunomaduro/larastan/extension.neon - ./vendor/larastan/larastan/extension.neon
parameters: parameters:
paths: paths:
@ -23,3 +23,4 @@ parameters:
paths: paths:
- src/Currency.php - src/Currency.php
- identifier: missingType.iterableValue - identifier: missingType.iterableValue
- identifier: unset.possiblyHookedProperty

View file

@ -44,7 +44,7 @@ class PriceFormatter
$formatted = ltrim($formatted, $currency->prefix()); $formatted = ltrim($formatted, $currency->prefix());
$formatted = rtrim($formatted, $currency->suffix()); $formatted = rtrim($formatted, $currency->suffix());
$removeNonDigits = preg_replace('/[^\d' . preg_quote($currency->decimalSeparator()) . ']/', '', $formatted); $removeNonDigits = preg_replace('/[^\d' . preg_quote($currency->decimalSeparator(), '/') . ']/', '', $formatted);
if (! is_string($removeNonDigits)) { if (! is_string($removeNonDigits)) {
throw new Exception('The formatted string could not be resolved to a valid number.'); throw new Exception('The formatted string could not be resolved to a valid number.');

View file

@ -4,8 +4,3 @@ use ArchTech\Money\Tests\TestCase;
use Pest\TestSuite; use Pest\TestSuite;
uses(ArchTech\Money\Tests\TestCase::class)->in('Pest'); uses(ArchTech\Money\Tests\TestCase::class)->in('Pest');
function pest(): TestCase
{
return TestSuite::getInstance()->test;
}

View file

@ -5,13 +5,13 @@ use ArchTech\Money\Exceptions\InvalidCurrencyException;
use ArchTech\Money\Tests\Currencies\CZK; use ArchTech\Money\Tests\Currencies\CZK;
test("a currency is invalid if it doesn't have a name", function () { test("a currency is invalid if it doesn't have a name", function () {
pest()->expectException(InvalidCurrencyException::class); $this->expectException(InvalidCurrencyException::class);
new Currency(rate: 2.0, code: 'CZK'); new Currency(rate: 2.0, code: 'CZK');
}); });
test("a currency is invalid if it doesn't have a code", function () { test("a currency is invalid if it doesn't have a code", function () {
pest()->expectException(InvalidCurrencyException::class); $this->expectException(InvalidCurrencyException::class);
new Currency(rate: 2.0, name: 'Czech Crown'); new Currency(rate: 2.0, name: 'Czech Crown');
}); });

View file

@ -170,7 +170,7 @@ test('an exception is thrown if none of the currencies match the prefix and suff
currencies()->remove(USD::class); currencies()->remove(USD::class);
pest()->expectException(CannotExtractCurrencyException::class); $this->expectException(CannotExtractCurrencyException::class);
Money::fromFormatted($formatted); Money::fromFormatted($formatted);
}); });
@ -178,7 +178,7 @@ test('an exception is thrown if multiple currencies are using the same prefix an
currencies()->add(['code' => 'USD2', 'name' => 'USD2', 'prefix' => '$']); currencies()->add(['code' => 'USD2', 'name' => 'USD2', 'prefix' => '$']);
$money = money(1000); $money = money(1000);
pest()->expectException(CannotExtractCurrencyException::class); $this->expectException(CannotExtractCurrencyException::class);
Money::fromFormatted($money->formatted()); Money::fromFormatted($money->formatted());
}); });