1 | <?php |
||
9 | class Temperature |
||
10 | { |
||
11 | /** |
||
12 | * Current temperature. |
||
13 | * @var Unit |
||
14 | */ |
||
15 | public $now; |
||
16 | |||
17 | /** |
||
18 | * The minimal temperature. |
||
19 | * @var Unit |
||
20 | */ |
||
21 | public $min; |
||
22 | |||
23 | /** |
||
24 | * The maximal temperature. |
||
25 | * @var Unit |
||
26 | */ |
||
27 | public $max; |
||
28 | |||
29 | /** |
||
30 | * The day temperature. |
||
31 | * Might be null. |
||
32 | * @var Unit |
||
33 | */ |
||
34 | public $day; |
||
35 | |||
36 | /** |
||
37 | * The morning temperature. |
||
38 | * Might be null. |
||
39 | * @var Unit |
||
40 | */ |
||
41 | public $morning; |
||
42 | |||
43 | /** |
||
44 | * The evening temperature. |
||
45 | * Might be null. |
||
46 | * @var Unit |
||
47 | */ |
||
48 | public $evening; |
||
49 | |||
50 | /** |
||
51 | * The night temperature. |
||
52 | * Might be null. |
||
53 | * @var Unit |
||
54 | */ |
||
55 | public $night; |
||
56 | |||
57 | /** |
||
58 | * Get the current temperature as a formatted string with unit. |
||
59 | * Unit will not be inlucded if Empty |
||
60 | * @return string The temperature formatted string with unit. |
||
61 | */ |
||
62 | 1 | public function __toString() |
|
66 | |||
67 | /** |
||
68 | * Creates new temperature object |
||
69 | * @param Unit $now The current temperature. |
||
70 | * @param Unit $min The minimal temperature. |
||
71 | * @param Unit $max The maximal temperature. |
||
72 | * @param Unit $day The day temperature. Might not be null. |
||
73 | * @param Unit $morning The morning temperature. Might not be null. |
||
74 | * @param Unit $evening The evening temperature. Might not be null. |
||
75 | * @param Unit $night The night temperature. Might not be null. |
||
76 | */ |
||
77 | 1 | function __construct( |
|
95 | |||
96 | /** |
||
97 | * Get the current temperature unit. |
||
98 | * This also converts 'celsius' to 'C' and 'fahrenheit' to 'F'. |
||
99 | * @return string The temperature unit. |
||
100 | */ |
||
101 | 3 | public function getUnit(): ?string |
|
105 | |||
106 | /** |
||
107 | * Get the current temperature value. |
||
108 | * @return float The value |
||
109 | */ |
||
110 | 1 | public function getValue(): float |
|
114 | |||
115 | /** |
||
116 | * Get the current temperature description. |
||
117 | * @return string Value's description. |
||
118 | */ |
||
119 | 1 | public function getDescription(): ?string |
|
123 | |||
124 | /** |
||
125 | * Get the current temperature as a formatted string with unit. |
||
126 | * @return string The current temperature as formatted string with unit. |
||
127 | */ |
||
128 | 2 | public function getFormatted(): string |
|
132 | } |
||
133 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.