| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Money |
||
| 6 | { |
||
| 7 | private int $amount; |
||
| 8 | private Currency $currency; |
||
| 9 | |||
| 10 | 3 | private function __construct(int $amount, Currency $currency) |
|
| 11 | { |
||
| 12 | 3 | $this->amount = $amount; |
|
| 13 | 3 | $this->currency = $currency; |
|
| 14 | 3 | } |
|
| 15 | |||
| 16 | 3 | public static function create(int $amount, Currency $currency): Money |
|
| 17 | { |
||
| 18 | 3 | return new self($amount, $currency); |
|
| 19 | } |
||
| 20 | |||
| 21 | 3 | public function amount(): int |
|
| 22 | { |
||
| 23 | 3 | return $this->amount; |
|
| 24 | } |
||
| 25 | |||
| 26 | 3 | public function amountFloat(): float |
|
| 27 | { |
||
| 28 | 3 | return (float)($this->amount() / pow(10, $this->currency->config()->decimals())); |
|
| 29 | } |
||
| 30 | |||
| 31 | 3 | public function currency(): Currency |
|
| 34 | } |
||
| 35 | |||
| 36 | 3 | public function formatted(string $thousandsSeparator = ',', string $decimalsSeparator = '.'): string |
|
| 37 | { |
||
| 38 | 3 | return $this->currency->value() . ' ' . |
|
| 47 |