From 129018cd3273a0cb9176014bd624de6a6d53cd6f Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Thu, 3 Nov 2022 15:47:51 +0100 Subject: [PATCH] Revert removing moneyh helper --- src/Helpers/helpers.php | 14 ++++++++++++++ tests/Helpers/HelpersTest.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Helpers/helpers.php b/src/Helpers/helpers.php index 4bb54251..a833c222 100644 --- a/src/Helpers/helpers.php +++ b/src/Helpers/helpers.php @@ -23,6 +23,20 @@ function object_to_array_recursive($object) } } +if (! function_exists('money')) { + /** + * Create a Money object from a Mollie Amount array. + * + * @param int|string $value + * @param string $currency + * @return \Money\Money + */ + function money($value, string $currency) + { + return new Money($value, new Currency($currency)); + } +} + if (! function_exists('decimal_to_money')) { /** * Create a Money object from a decimal string / currency pair. diff --git a/tests/Helpers/HelpersTest.php b/tests/Helpers/HelpersTest.php index 91afc3c7..c059cba3 100644 --- a/tests/Helpers/HelpersTest.php +++ b/tests/Helpers/HelpersTest.php @@ -11,7 +11,7 @@ class HelpersTest extends TestCase /** @test */ public function testMoney() { - $money = new Money(1234, new Currency('EUR')); + $money = money(1234, 'EUR'); $this->assertInstanceOf(Money::class, $money); $this->assertTrue(Money::EUR(1234)->equals($money));