You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CurrencyConverter.php 578B

123456789101112131415161718192021
  1. <?php
  2. namespace App\Utilities\Currency;
  3. class CurrencyConverter
  4. {
  5. public static function convertBalance(int $balance, string $oldCurrency, string $newCurrency): int
  6. {
  7. return money($balance, $oldCurrency)->swapAmountFor($newCurrency);
  8. }
  9. public static function prepareForMutator(int $balance, string $currency): string
  10. {
  11. return money($balance, $currency)->formatSimple();
  12. }
  13. public static function prepareForAccessor(string $balance, string $currency): int
  14. {
  15. return money($balance, $currency, true)->getAmount();
  16. }
  17. }