1 | <?php |
||
22 | class Angle { |
||
23 | |||
24 | use FloatValueTrait; |
||
25 | |||
26 | /** |
||
27 | * Unit "degree". |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | const UNIT_DEGREE = "degree"; |
||
32 | |||
33 | /** |
||
34 | * Unit "radian". |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | const UNIT_RADIAN = "radian"; |
||
39 | |||
40 | /** |
||
41 | * Units. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $units; |
||
46 | |||
47 | /** |
||
48 | * Constructor. |
||
49 | * |
||
50 | * @param float $value The value. |
||
51 | * @param string $units The units. |
||
52 | */ |
||
53 | public function __construct(float $value, string $units = self::UNIT_RADIAN) { |
||
57 | |||
58 | /** |
||
59 | * Degree. |
||
60 | * |
||
61 | * @return float Returns the degree. |
||
62 | */ |
||
63 | public function deg(): float { |
||
71 | |||
72 | /** |
||
73 | * Get the unit. |
||
74 | * |
||
75 | * @return string Returns the unit. |
||
76 | */ |
||
77 | public function getUnits(): string { |
||
80 | |||
81 | /** |
||
82 | * Determines if this angle is in degree. |
||
83 | * |
||
84 | * @return bool Returns true in case of success, false otherwise. |
||
85 | */ |
||
86 | public function isDegree(): bool { |
||
89 | |||
90 | /** |
||
91 | * Determines if this angle is in radian. |
||
92 | * |
||
93 | * @return bool Returns true in case of success, false otherwise. |
||
94 | */ |
||
95 | public function isRadian(): bool { |
||
98 | |||
99 | /** |
||
100 | * Radian. |
||
101 | * |
||
102 | * @return float Returns the radian. |
||
103 | */ |
||
104 | public function rad(): float { |
||
112 | |||
113 | /** |
||
114 | * Set the unit. |
||
115 | * |
||
116 | * @param string $units The unit. |
||
117 | * @return Angle Returns this angle. |
||
118 | */ |
||
119 | protected function setUnits(string $units): Angle { |
||
123 | } |
||
124 |