| Total Complexity | 6 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | final class NumberPerUnit |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @uses get_as_long |
||
| 18 | * @uses get_as_short |
||
| 19 | * @uses get_as_narrow |
||
| 20 | */ |
||
| 21 | use AccessorTrait; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param float|int|numeric-string $number |
||
|
|
|||
| 25 | */ |
||
| 26 | public function __construct( |
||
| 27 | private readonly float|int|string $number, |
||
| 28 | private readonly string $number_unit, |
||
| 29 | private readonly string $per_unit, |
||
| 30 | private readonly Units $units |
||
| 31 | ) { |
||
| 32 | } |
||
| 33 | |||
| 34 | public function __toString(): string |
||
| 35 | { |
||
| 36 | return $this->as(Units::DEFAULT_LENGTH); |
||
| 37 | } |
||
| 38 | |||
| 39 | private function get_as_long(): string |
||
| 40 | { |
||
| 41 | return $this->as(UnitLength::LONG); |
||
| 42 | } |
||
| 43 | |||
| 44 | private function get_as_short(): string |
||
| 45 | { |
||
| 46 | return $this->as(UnitLength::SHORT); |
||
| 47 | } |
||
| 48 | |||
| 49 | private function get_as_narrow(): string |
||
| 50 | { |
||
| 51 | return $this->as(UnitLength::NARROW); |
||
| 52 | } |
||
| 53 | |||
| 54 | private function as(UnitLength $length): string |
||
| 61 | ); |
||
| 62 | } |
||
| 63 | } |
||
| 64 |