Completed
Push — uv-index ( 9af66d )
by Christian
02:24
created

Temperature   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 111
ccs 19
cts 19
cp 1
rs 10
c 2
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A getUnit() 0 4 1
A getValue() 0 4 1
A getDescription() 0 4 1
A getFormatted() 0 4 1
A __construct() 0 10 1
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 1
    public function __toString()
66
    {
67 1
        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 1
    public function getUnit()
76
    {
77 1
        return $this->now->getUnit();
78
    }
79
80
    /**
81
     * Returns the current temperature.
82
     *
83
     * @return string The current temperature.
84
     */
85 1
    public function getValue()
86
    {
87 1
        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 1
    public function getDescription()
96
    {
97 1
        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 1
    public function getFormatted()
106
    {
107 1
        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 24
    public function __construct(Unit $now, Unit $min, Unit $max, Unit $day = null, Unit $morning = null, Unit $evening = null, Unit $night = null)
124
    {
125 24
        $this->now = $now;
126 24
        $this->min = $min;
127 24
        $this->max = $max;
128 24
        $this->day = $day;
129 24
        $this->morning = $morning;
130 24
        $this->evening = $evening;
131 24
        $this->night = $night;
132 24
    }
133
}
134