Hour::getSummary()   A
last analyzed

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 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 *
4
 * PHP version 5.5
5
 *
6
 * @package Forecast\Model
7
 * @author  Sergey V.Kuzin <[email protected]>
8
 * @license MIT
9
 */
10
declare(strict_types=1);
11
namespace Forecast\Model;
12
13
14
use Forecast\ForecastItemInterface;
15
16
class Hour implements  ForecastItemInterface
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "ForecastItemInterface"; 2 found
Loading history...
17
{
18
    /** @var \DateTime  */
19
    protected $date;
20
    protected $summary;
21
22
    /** @var Temperature  */
23
    protected $temperature;
24
25
    /** @var Wind */
26
    protected $wind;
27
28
    /** @var Humidity */
29
    protected $humidity;
30
31
    /** @var Precipitation */
32
    protected $precipitation;
33
34
    /** @var string */
35
    protected $icon;
36
37
    /**
38
     * @api
39
     *
40
     * @return string
41
     */
42
    public function getSummary(): string
43
    {
44
        return $this->summary;
45
    }
46
47
    /**
48
     * @api
49
     *
50
     * @return Temperature
51
     */
52
    public function getTemperature(): Temperature
53
    {
54
        return $this->temperature;
55
    }
56
57
    /**
58
     * @api
59
     *
60
     * @return Wind
61
     */
62
    public function getWind(): Wind
63
    {
64
        return $this->wind;
65
    }
66
67
    /**
68
     * @api
69
     *
70
     * @return string
71
     */
72
    public function __toString(): string 
73
    {
74
        return (string)$this->getSummary();
75
    }
76
77
    /**
78
     * @return \DateTime
79
     */
80
    public function getDate(): \DateTime
81
    {
82
        return $this->date;
83
    }
84
85
    /**
86
     * @param array $data
87
     * @return ForecastItemInterface
88
     */
89
    public function setData(array $data): ForecastItemInterface
90
    {
91
        $this->date = $data['date'];
92
        $this->summary = $data['summary'];
93
        $this->temperature = (new Temperature())->setData($data['temperature']);
94
        $this->wind = (new Wind())->setData($data['wind']);
95
        $this->humidity = (new Humidity())->setData($data['humidity']);
96
        $this->precipitation = (new Precipitation())->setData($data['precipitation']);
97
        $this->icon = $data['icon'];
98
        return $this;
99
    }
100
101
    /**
102
     * @return Humidity
103
     */
104
    public function getHumidity(): Humidity
105
    {
106
        return $this->humidity;
107
    }
108
109
    /**
110
     * @return Precipitation
111
     */
112
    public function getPrecipitation(): Precipitation
113
    {
114
        return $this->precipitation;
115
    }
116
117
    /**
118
     * @return string
119
     */
120
    public function getIcon(): string
121
    {
122
        return $this->icon;
123
    }
124
}
125