From 560129f138dea556affa51c72c8e63b1390f938e Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Wed, 28 Oct 2026 10:12:52 +0000 Subject: [PATCH] feat!: update to use `brick/math` 1.x --- composer.json | 2 +- src/Casts/NumberFromDecimal.php | 10 ++++++++-- src/Number.php | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a87cb5f..b904b3e 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^8.4", - "brick/math": "^0.14.4", + "brick/math": "^1.0", "webonyx/graphql-php": "^15.30" }, "require-dev": { diff --git a/src/Casts/NumberFromDecimal.php b/src/Casts/NumberFromDecimal.php index 05787d4..79fbf40 100644 --- a/src/Casts/NumberFromDecimal.php +++ b/src/Casts/NumberFromDecimal.php @@ -15,14 +15,20 @@ */ class NumberFromDecimal implements CastsAttributes { - /** @param class-string $class */ + /** + * @param non-negative-int $decimals + * @param class-string $class + */ public function __construct( private readonly int $decimals = 2, private readonly string $class = Number::class, ) { } - /** @param class-string $class */ + /** + * @param non-negative-int $decimals + * @param class-string $class + */ public static function using( int $decimals = 2, string $class = Number::class, diff --git a/src/Number.php b/src/Number.php index c4f6b9e..3696fe5 100755 --- a/src/Number.php +++ b/src/Number.php @@ -10,10 +10,12 @@ class Number { + /** @var non-negative-int|null */ protected int|null $decimals = null; protected RoundingMode $roundingMode = RoundingMode::HalfUp; + /** @param non-negative-int|null $decimals */ final protected function __construct( protected BigDecimal $value, int|null $decimals = null, @@ -25,6 +27,7 @@ final protected function __construct( $this->validate(); } + /** @param non-negative-int|null $decimals */ public static function of(string|int|float|BigNumber|Number $value, int|null $decimals = null): static { if ($value instanceof BigNumber) { @@ -82,6 +85,7 @@ public function div(string|int|float|BigNumber|Number $value): static return $this->newInstanceWithValue($result); } + /** @param non-negative-int $scale */ public function round(int $scale): static { return static::of($this->value->toScale($scale, $this->roundingMode), $this->decimals);