Skip to content

Commit

Permalink
Revert removing moneyh helper
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervanhooft committed Nov 3, 2022
1 parent 746594f commit 129018c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/Helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/Helpers/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 129018c

Please sign in to comment.