Total Complexity | 7 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class DarkSky |
||
13 | { |
||
14 | private $config; |
||
15 | private $curl; |
||
16 | |||
17 | /** |
||
18 | * Constructor, allow for $di to be injected. |
||
19 | * |
||
20 | * @param array $config container |
||
21 | */ |
||
22 | 2 | public function __construct(Array $config) |
|
23 | { |
||
24 | 2 | $this->config = $config; |
|
25 | 2 | $this->curl = new Curl(); |
|
26 | 2 | } |
|
27 | |||
28 | /** |
||
29 | * Set config |
||
30 | */ |
||
31 | 2 | public function setConfig(Array $config) |
|
34 | 2 | } |
|
35 | |||
36 | /** |
||
37 | * Function that takes an coordinate and gets upcomming weather. |
||
38 | * |
||
39 | * @param string $latlon |
||
40 | * |
||
41 | * @return array $result |
||
42 | */ |
||
43 | 2 | public function getWeatherComing(String $latlon) : array |
|
44 | { |
||
45 | 2 | $res = []; |
|
46 | 2 | $res[0] = $this->curl->single($this->config["url"] . $latlon . $this->config["single"]); |
|
47 | 2 | $size = count($res[0]["daily"]["data"]); |
|
48 | 2 | for ($i = 0; $i < $size; $i++) { |
|
49 | 2 | $time = $res[0]["daily"]["data"][$i]["time"]; |
|
50 | 2 | $res[0]["daily"]["data"][$i]["date"] = date("Y-m-d", $time); |
|
51 | } |
||
52 | 2 | return $res; |
|
53 | } |
||
54 | |||
55 | |||
56 | /** |
||
57 | * Function that takes an coordinate and get past 30 days weather |
||
58 | * |
||
59 | * @param string $latlon |
||
60 | * |
||
61 | * @return array $result |
||
62 | */ |
||
63 | 2 | public function getWeatherPast(String $latlon) : array |
|
79 | } |
||
80 | } |
||
81 |