1 | <?php |
||
11 | final class Percentage |
||
12 | { |
||
13 | const DECIMALS = 6; |
||
14 | |||
15 | /** |
||
16 | * @var float |
||
17 | */ |
||
18 | private $percentage; |
||
19 | |||
20 | /** |
||
21 | * @param string $percentage |
||
22 | */ |
||
23 | 7 | public function __construct($percentage) |
|
27 | |||
28 | /** |
||
29 | * @param Percentage $other |
||
30 | * |
||
31 | * @return bool |
||
32 | */ |
||
33 | 1 | public function equals(Percentage $other) |
|
37 | |||
38 | /** |
||
39 | * @return float |
||
40 | */ |
||
41 | 6 | public function getPercent() |
|
45 | |||
46 | /** |
||
47 | * @param Percentage $addend |
||
48 | * |
||
49 | * @return Percentage |
||
50 | */ |
||
51 | 1 | public function add(Percentage $addend) |
|
57 | |||
58 | /** |
||
59 | * @param Percentage $subtrahend |
||
60 | * |
||
61 | * @return Percentage |
||
62 | */ |
||
63 | 1 | public function sub(Percentage $subtrahend) |
|
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | 3 | public function __toString() |
|
77 | |||
78 | /** |
||
79 | * @param string|float|int $value |
||
80 | * |
||
81 | * @return float |
||
82 | */ |
||
83 | 7 | private function convert($value) |
|
87 | |||
88 | /** |
||
89 | * @param float $percent |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 3 | private function invert($percent) |
|
97 | } |
||
98 |