| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | final class Storage |
||
| 19 | { |
||
| 20 | public const UNITS = [ |
||
| 21 | 'bouteille', |
||
| 22 | 'boite', |
||
| 23 | 'carton', |
||
| 24 | 'colis', |
||
| 25 | 'kilogramme', |
||
| 26 | 'litre', |
||
| 27 | 'pièce', |
||
| 28 | 'poche', |
||
| 29 | 'portion', |
||
| 30 | ]; |
||
| 31 | |||
| 32 | private string $unit; |
||
| 33 | private float $quantity; |
||
| 34 | |||
| 35 | public function __construct(string $unit, float $quantity) |
||
| 39 | } |
||
| 40 | |||
| 41 | public static function fromArray(array $storage): self |
||
| 42 | { |
||
| 43 | $unit = static::isValidUnit($storage[0]); |
||
| 44 | $quantity = static::isValidQuantity($storage[1]); |
||
| 45 | |||
| 46 | return new self($unit, $quantity); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function toArray(): array |
||
| 52 | } |
||
| 53 | |||
| 54 | private static function isValidUnit(string $unit): string |
||
| 61 | } |
||
| 62 | |||
| 63 | private static function isValidQuantity(float $quantity): float |
||
| 72 |