@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function fetchProvinces() |
21 | 21 | { |
22 | 22 | $this->fetchCitys(); |
23 | - $this->_toArrayCall = function ($array) { |
|
23 | + $this->_toArrayCall = function($array) { |
|
24 | 24 | return Arrays::columns($array, ['code', 'name']); |
25 | 25 | }; |
26 | 26 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $res = Http::get('http://www.nmc.cn/f/rest/province/' . $provinceCode); |
40 | 40 | $this->_result = Json::decode($res); |
41 | - $this->_toArrayCall = function ($array) { |
|
41 | + $this->_toArrayCall = function($array) { |
|
42 | 42 | return Arrays::columns($array, ['code', 'city', 'province']); |
43 | 43 | }; |
44 | 44 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | $res = Http::get('http://www.nmc.cn/f/rest/real/' . $cityId); |
74 | 74 | $this->_result = Json::decode($res); |
75 | - $this->_toArrayCall = function ($array) { |
|
75 | + $this->_toArrayCall = function($array) { |
|
76 | 76 | return Arrays::columns($array, [ |
77 | 77 | 'publish_time', |
78 | 78 | 'airpressure' => 'weather.airpressure', |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $res = Http::get('http://www.nmc.cn/f/rest/aqi/' . $cityId); |
109 | 109 | $this->_result = Json::decode($res); |
110 | - $this->_toArrayCall = function ($array) { |
|
110 | + $this->_toArrayCall = function($array) { |
|
111 | 111 | return Arrays::columns($array, [ |
112 | 112 | 'forecasttime', |
113 | 113 | 'aq', |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return static |
134 | 134 | */ |
135 | - public function fetchToday($cityId){ |
|
135 | + public function fetchToday($cityId) { |
|
136 | 136 | $res = Http::get('http://www.nmc.cn/f/rest/passed/' . $cityId); |
137 | 137 | $this->_result = Json::decode($res); |
138 | - $this->_toArrayCall = function ($array) { |
|
138 | + $this->_toArrayCall = function($array) { |
|
139 | 139 | return Arrays::columns($array, [ |
140 | 140 | 'time', |
141 | 141 | 'humidity', |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | 'pageSize' => $pageSize, |
32 | 32 | ]); |
33 | 33 | $this->_result = Json::get($res, 'data', []); |
34 | - $this->_toArrayCall = function ($array) { |
|
34 | + $this->_toArrayCall = function($array) { |
|
35 | 35 | return Arrays::columns($array, [ |
36 | 36 | 'id' => 'd_id', |
37 | 37 | 'name' => 'd_name', |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'pageSize' => $pageSize, |
61 | 61 | ]); |
62 | 62 | $this->_result = Json::get($res, 'data', []); |
63 | - $this->_toArrayCall = function ($array) { |
|
63 | + $this->_toArrayCall = function($array) { |
|
64 | 64 | return Arrays::columns($array, [ |
65 | 65 | 'id' => 'd_id', |
66 | 66 | 'name' => 'd_name', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | 'd_id' => $id, |
86 | 86 | ]); |
87 | 87 | $this->_result = Json::get($res, 'data', []); |
88 | - $this->_toArrayCall = function ($array) { |
|
88 | + $this->_toArrayCall = function($array) { |
|
89 | 89 | return Arrays::columns($array, [ |
90 | 90 | 'id' => 'd_id', |
91 | 91 | 'name' => 'd_name', |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'lang' => 'd_lang', |
97 | 97 | 'year' => 'd_year', |
98 | 98 | 'description' => 'd_content', |
99 | - 'episodes' => function ($array) { |
|
99 | + 'episodes' => function($array) { |
|
100 | 100 | $episodes = explode('#', I::get($array, 'd_playurl')); |
101 | 101 | return Arrays::explode('$', $episodes); |
102 | 102 | }, |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | } |
61 | 61 | return $result; |
62 | 62 | } elseif (is_array($mixed) || is_object($mixed)) { // 数组和对象 |
63 | - if(false === is_string($keyString) && is_callable($keyString)){ |
|
63 | + if (false === is_string($keyString) && is_callable($keyString)) { |
|
64 | 64 | $mixed = self::call($keyString, [$mixed]); |
65 | - }else{ |
|
65 | + } else { |
|
66 | 66 | $keyArray = explode('.', $keyString); |
67 | 67 | foreach ($keyArray as $key) { |
68 | 68 | if (is_array($mixed)) { |
69 | 69 | if (array_key_exists($key, $mixed) && null !== $mixed[$key]) { |
70 | 70 | $mixed = $mixed[$key]; |
71 | - }else { |
|
71 | + } else { |
|
72 | 72 | return $defaultValue; |
73 | 73 | } |
74 | 74 | } elseif (is_object($mixed)) { |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | } |
93 | 93 | return $mixed; |
94 | 94 | } elseif (is_string($mixed) || is_numeric($mixed)) { // 字符串或数字 |
95 | - $pos = (int) $keyString; |
|
96 | - $length = null === $defaultValue ? 1 : (int) $defaultValue; |
|
95 | + $pos = (int)$keyString; |
|
96 | + $length = null === $defaultValue ? 1 : (int)$defaultValue; |
|
97 | 97 | return Strings::sub($mixed, $pos, $length); |
98 | 98 | } elseif (null === $mixed) { // null |
99 | 99 | return $defaultValue; |
@@ -62,13 +62,13 @@ |
||
62 | 62 | } elseif (is_array($mixed) || is_object($mixed)) { // 数组和对象 |
63 | 63 | if(false === is_string($keyString) && is_callable($keyString)){ |
64 | 64 | $mixed = self::call($keyString, [$mixed]); |
65 | - }else{ |
|
65 | + } else{ |
|
66 | 66 | $keyArray = explode('.', $keyString); |
67 | 67 | foreach ($keyArray as $key) { |
68 | 68 | if (is_array($mixed)) { |
69 | 69 | if (array_key_exists($key, $mixed) && null !== $mixed[$key]) { |
70 | 70 | $mixed = $mixed[$key]; |
71 | - }else { |
|
71 | + } else { |
|
72 | 72 | return $defaultValue; |
73 | 73 | } |
74 | 74 | } elseif (is_object($mixed)) { |