1 | <?php |
||
18 | abstract class AbstractConverter implements ConverterInterface |
||
19 | { |
||
20 | |||
21 | const MAX_DECIMALS = 999; |
||
22 | |||
23 | /** |
||
24 | * @var Unit[] List of convertible units |
||
25 | */ |
||
26 | protected $units = []; |
||
27 | |||
28 | /** |
||
29 | * @return string |
||
30 | */ |
||
31 | abstract public function getName(): string; |
||
32 | |||
33 | /** |
||
34 | * @param ConvertibleValue $from |
||
35 | * @param Unit $to |
||
36 | * @return ConvertibleValue |
||
37 | */ |
||
38 | 68 | public function convert(ConvertibleValue $from, Unit $to): ConvertibleValue |
|
50 | |||
51 | /** |
||
52 | * @param array $units |
||
53 | */ |
||
54 | 68 | protected function validate(array $units) |
|
63 | |||
64 | /** |
||
65 | * @param ConvertibleValue $cv |
||
66 | */ |
||
67 | 61 | protected function normalize(ConvertibleValue $cv) |
|
72 | |||
73 | /** |
||
74 | * @param ConvertibleValue $from The convertible to be converted |
||
75 | * @param Unit $to Unit to which is to be converted |
||
76 | */ |
||
77 | 61 | protected function convertTo(ConvertibleValue $from, Unit $to) |
|
82 | |||
83 | /** |
||
84 | * @return array |
||
85 | */ |
||
86 | public function getUnits(): array |
||
90 | |||
91 | } |