Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
laravel: [10, 11]
laravel: [10, 11, 12]

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
},
"require": {
"php": "^8.2",
"illuminate/support": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0|^12.0",
"archtechx/helpers": "^0.3.2"
},
"require-dev": {
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.0",
"phpstan/phpstan": "^1.9.8",
"pestphp/pest-plugin-laravel": "^2.0",
"nunomaduro/larastan": "^2.4"
"orchestra/testbench": "^8.0|^9.0|^10.0",
"pestphp/pest": "^2.0|^3.7",
"phpstan/phpstan": "^1.9.8|^2.1",
"pestphp/pest-plugin-laravel": "^2.0|^3.1",
"larastan/larastan": "^2.4|^3.0"
},
"extra": {
"laravel": {
Expand Down
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:
paths:
Expand All @@ -23,3 +23,4 @@ parameters:
paths:
- src/Currency.php
- identifier: missingType.iterableValue
- identifier: unset.possiblyHookedProperty
2 changes: 1 addition & 1 deletion src/PriceFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function resolve(string $formatted, Currency $currency, array $ove
$formatted = ltrim($formatted, $currency->prefix());
$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)) {
throw new Exception('The formatted string could not be resolved to a valid number.');
Expand Down
5 changes: 0 additions & 5 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@
use Pest\TestSuite;

uses(ArchTech\Money\Tests\TestCase::class)->in('Pest');

function pest(): TestCase
{
return TestSuite::getInstance()->test;
}
4 changes: 2 additions & 2 deletions tests/Pest/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use ArchTech\Money\Tests\Currencies\CZK;

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');
});

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');
});
Expand Down
4 changes: 2 additions & 2 deletions tests/Pest/MoneyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@

currencies()->remove(USD::class);

pest()->expectException(CannotExtractCurrencyException::class);
$this->expectException(CannotExtractCurrencyException::class);
Money::fromFormatted($formatted);
});

test('an exception is thrown if multiple currencies are using the same prefix and suffix', function () {
currencies()->add(['code' => 'USD2', 'name' => 'USD2', 'prefix' => '$']);
$money = money(1000);

pest()->expectException(CannotExtractCurrencyException::class);
$this->expectException(CannotExtractCurrencyException::class);
Money::fromFormatted($money->formatted());
});

Expand Down
Loading