| Conditions | 5 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public static function buildMoney(string $price, string $currency): ?Money |
||
| 15 | { |
||
| 16 | if (!is_numeric($price)) { |
||
| 17 | throw new \InvalidArgumentException('price of the Money must be numeric'); |
||
| 18 | } |
||
| 19 | if (!self::checkFloat($price)) { |
||
| 20 | return new Money($price, new Currency($currency)); |
||
| 21 | } |
||
| 22 | if (!is_int($price) && ($price * 100) == ((int) ($price * 100))) { |
||
|
|
|||
| 23 | return (new DecimalMoneyParser(new ISOCurrencies()))->parse($price, new Currency($currency)); |
||
| 24 | } |
||
| 25 | return new Money( |
||
| 26 | (int) ($price * self::calculatePriceMultiplier($price)), |
||
| 27 | new Currency($currency) |
||
| 28 | ); |
||
| 53 |