Skip to content

Instantly share code, notes, and snippets.

@osteel
Created July 2, 2022 12:50
Show Gist options
  • Save osteel/ae31d33b03ef8ce7475295e1eedaf013 to your computer and use it in GitHub Desktop.
Save osteel/ae31d33b03ef8ce7475295e1eedaf013 to your computer and use it in GitHub Desktop.
PHP compatibility demo – library v1
<?php
namespace Osteel\PhpCompatibilityDemo;
use Money\Currencies\ISOCurrencies;
use Money\Money;
class CurrencyHelper
{
public function isSame(Money ...$amounts): bool
{
if (count($amounts) === 1) {
return true;
}
$first = array_shift($amounts);
return $first->isSameCurrency(...$amounts);
}
public function numericCode(Money $amount): int
{
return (new ISOCurrencies())->numericCodeFor($amount->getCurrency());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment