Created
July 2, 2022 12:50
-
-
Save osteel/ae31d33b03ef8ce7475295e1eedaf013 to your computer and use it in GitHub Desktop.
PHP compatibility demo – library v1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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