diff --git a/src/Money.php b/src/Money.php index bd30a9d..810bd0b 100644 --- a/src/Money.php +++ b/src/Money.php @@ -49,6 +49,7 @@ class Money implements Arrayable, Jsonable, JsonSerializable use MoneyParserTrait; use Macroable { Macroable::__call as macroCall; + Macroable::__callStatic as macroCallStatic; } /** @@ -231,6 +232,10 @@ public static function convert(\Money\Money $instance) */ public static function __callStatic($method, array $arguments) { + if (static::hasMacro($method)) { + return static::macroCallStatic($method, $arguments); + } + if (in_array($method, ['min', 'max', 'avg', 'sum'])) { $result = call_user_func_array([\Money\Money::class, $method], static::getArguments($arguments)); diff --git a/tests/MoneyTest.php b/tests/MoneyTest.php index ebeb860..347cbe8 100644 --- a/tests/MoneyTest.php +++ b/tests/MoneyTest.php @@ -233,5 +233,10 @@ public function testMacroable() 'some-return-value', $money->someMacro() ); + + static::assertEquals( + 'some-return-value', + Money::someMacro() + ); } }