Completed
Pull Request — master (#77)
by Alex
02:09
created

Temperature::getUnit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
4
 *
5
 * @license MIT
6
 *
7
 * Please see the LICENSE file distributed with this source code for further
8
 * information regarding copyright and licensing.
9
 *
10
 * Please visit the following links to read about the usage policies and the license of
11
 * OpenWeatherMap before using this class:
12
 *
13
 * @see http://www.OpenWeatherMap.org
14
 * @see http://www.OpenWeatherMap.org/terms
15
 * @see http://openweathermap.org/appid
16
 */
17
18
namespace Cmfcmf\OpenWeatherMap\Util;
19
20
/**
21
 * The temperature class representing a temperature object.
22
 */
23
class Temperature
24
{
25
    /**
26
     * @var Unit The current temperature.
27
     */
28
    public $now;
29
30
    /**
31
     * @var Unit The minimal temperature.
32
     */
33
    public $min;
34
35
    /**
36
     * @var Unit The maximal temperature.
37
     */
38
    public $max;
39
40
    /**
41
     * @var Unit The day temperature. Might not be null.
42
     */
43
    public $day;
44
    
45
    /**
46
     * @var Unit The morning temperature. Might not be null.
47
     */
48
    public $morning;
49
    
50
    /**
51
     * @var Unit The evening temperature. Might not be null.
52
     */
53
    public $evening;
54
    
55
    /**
56
     * @var Unit The night temperature. Might not be null.
57
     */
58
    public $night;
59
60
    /**
61
     * Returns the current temperature as formatted string.
62
     *
63
     * @return string The current temperature as a formatted string.
64
     */
65
    public function __toString()
66
    {
67
        return $this->now->__toString();
68
    }
69
70
    /**
71
     * Returns the current temperature's unit.
72
     *
73
     * @return string The current temperature's unit.
74
     */
75
    public function getUnit()
76
    {
77
        return $this->now->getUnit();
78
    }
79
80
    /**
81
     * Returns the current temperature.
82
     *
83
     * @return string The current temperature.
84
     */
85
    public function getValue()
86
    {
87
        return $this->now->getValue();
88
    }
89
90
    /**
91
     * Returns the current temperature's description.
92
     *
93
     * @return string The current temperature's description.
94
     */
95
    public function getDescription()
96
    {
97
        return $this->now->getDescription();
98
    }
99
100
    /**
101
     * Returns the current temperature as formatted string.
102
     *
103
     * @return string The current temperature as formatted string.
104
     */
105
    public function getFormatted()
106
    {
107
        return $this->now->getFormatted();
108
    }
109
110
    /**
111
     * Create a new temperature object.
112
     *
113
     * @param Unit $now The current temperature.
114
     * @param Unit $min The minimal temperature.
115
     * @param Unit $max The maximal temperature.
116
     * @param Unit $day The day temperature. Might not be null.
117
     * @param Unit $morning The morning temperature. Might not be null.
118
     * @param Unit $evening The evening temperature. Might not be null.
119
     * @param Unit $night The night temperature. Might not be null.
120
     *
121
     * @internal
122
     */
123
    public function __construct(Unit $now, Unit $min, Unit $max, Unit $day = null, Unit $morning = null, Unit $evening = null, Unit $night = null)
124
    {
125
        $this->now = $now;
126
        $this->min = $min;
127
        $this->max = $max;
128
        $this->day = $day;
129
        $this->morning = $morning;
130
        $this->evening = $evening;
131
        $this->night = $night;
132
    }
133
}
134