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

History::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 9
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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;
19
20
use Cmfcmf\OpenWeatherMap\Util\Temperature;
21
use Cmfcmf\OpenWeatherMap\Util\Unit;
22
use Cmfcmf\OpenWeatherMap\Util\Weather;
23
use Cmfcmf\OpenWeatherMap\Util\Wind;
24
25
/**
26
 * Class WeatherHistory.
27
 */
28
class History
29
{
30
    /**
31
     * The city object.
32
     *
33
     * @var Util\City
34
     */
35
    public $city;
36
37
    /**
38
     * The temperature object.
39
     *
40
     * @var Util\Temperature
41
     */
42
    public $temperature;
43
44
    /**
45
     * @var Util\Unit
46
     */
47
    public $humidity;
48
49
    /**
50
     * @var Util\Unit
51
     */
52
    public $pressure;
53
54
    /**
55
     * @var Util\Wind
56
     */
57
    public $wind;
58
59
    /**
60
     * @var Util\Unit
61
     */
62
    public $clouds;
63
64
    /**
65
     * @var Util\Unit
66
     */
67
    public $precipitation;
68
69
    /**
70
     * @var Util\Weather
71
     */
72
    public $weather;
73
74
    /**
75
     * @var \DateTime The time of the history.
76
     */
77
    public $time;
78
79
    /**
80
     * @param $city
81
     * @param $weather
82
     * @param $temperature
83
     * @param $pressure
84
     * @param $humidity
85
     * @param $clouds
86
     * @param $rain
87
     * @param $wind
88
     * @param $time
89
     *
90
     * @internal
91
     */
92 6
    public function __construct($city, $weather, $temperature, $pressure, $humidity, $clouds, $rain, $wind, $time)
93
    {
94 6
        $this->city = $city;
95 6
        $this->weather = new Weather($weather['id'], $weather['description'], $weather['icon']);
96 6
        $this->temperature = new Temperature(new Unit($temperature['now'] - 273.15, "\xB0C"), new Unit($temperature['min'] - 273.15, "\xB0C"), new Unit($temperature['max'] - 273.15, "\xB0C"));
97 6
        $this->pressure = new Unit($pressure, 'kPa');
98 6
        $this->humidity = new Unit($humidity, '%');
99 6
        $this->clouds = new Unit($clouds, '%');
100 6
        $this->precipitation = new Unit($rain['val'], $rain['unit']);
101 6
        $this->wind = new Wind(new Unit($wind['speed']), new Unit($wind['deg']));
102 6
        $this->time = $time;
103 6
    }
104
}
105