@@ -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)) { |
@@ -64,10 +64,10 @@ |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | $error = $this->getError(); |
| 67 | - if(is_array($error)){ |
|
| 67 | + if (is_array($error)) { |
|
| 68 | 68 | return $error; |
| 69 | 69 | } |
| 70 | - throw new Exception((string) $error); |
|
| 70 | + throw new Exception((string)$error); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -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 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function fetchCitys($provinceCode = null) |
| 38 | 38 | { |
| 39 | 39 | $this->_result = (array)Json::decode(Http::get('http://www.nmc.cn/f/rest/province/' . $provinceCode)); |
| 40 | - $this->_toArrayCall = function ($array) { |
|
| 40 | + $this->_toArrayCall = function($array) { |
|
| 41 | 41 | return Arrays::columns($array, ['code', 'city', 'province']); |
| 42 | 42 | }; |
| 43 | 43 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function fetchWeather($cityId) |
| 71 | 71 | { |
| 72 | 72 | $this->_result = (array)Json::decode(Http::get('http://www.nmc.cn/f/rest/real/' . $cityId)); |
| 73 | - $this->_toArrayCall = function ($array) { |
|
| 73 | + $this->_toArrayCall = function($array) { |
|
| 74 | 74 | return Arrays::columns($array, [ |
| 75 | 75 | 'publish_time', |
| 76 | 76 | 'airpressure' => 'weather.airpressure', |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | public function fetchAirQuality($cityId) |
| 105 | 105 | { |
| 106 | 106 | $this->_result = (array)Json::decode(Http::get('http://www.nmc.cn/f/rest/aqi/' . $cityId)); |
| 107 | - $this->_toArrayCall = function ($array) { |
|
| 107 | + $this->_toArrayCall = function($array) { |
|
| 108 | 108 | return Arrays::columns($array, [ |
| 109 | 109 | 'forecasttime', |
| 110 | 110 | 'aq', |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return static |
| 131 | 131 | */ |
| 132 | - public function fetchToday($cityId){ |
|
| 132 | + public function fetchToday($cityId) { |
|
| 133 | 133 | $this->_result = (array)Json::decode(Http::get('http://www.nmc.cn/f/rest/passed/' . $cityId)); |
| 134 | - $this->_toArrayCall = function ($array) { |
|
| 134 | + $this->_toArrayCall = function($array) { |
|
| 135 | 135 | return Arrays::columns($array, [ |
| 136 | 136 | 'time', |
| 137 | 137 | 'humidity', |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'page' => $page, |
| 31 | 31 | 'pageSize' => $pageSize, |
| 32 | 32 | ]), 'data', []); |
| 33 | - $this->_toArrayCall = function ($array) { |
|
| 33 | + $this->_toArrayCall = function($array) { |
|
| 34 | 34 | return Arrays::columns($array, [ |
| 35 | 35 | 'id' => 'd_id', |
| 36 | 36 | 'name' => 'd_name', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'page' => $page, |
| 59 | 59 | 'pageSize' => $pageSize, |
| 60 | 60 | ]), 'data', []); |
| 61 | - $this->_toArrayCall = function ($array) { |
|
| 61 | + $this->_toArrayCall = function($array) { |
|
| 62 | 62 | return Arrays::columns($array, [ |
| 63 | 63 | 'id' => 'd_id', |
| 64 | 64 | 'name' => 'd_name', |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $this->_result = (array)Json::get(Http::get('http://api.jinsapi.com/yingshi/getVodById', [ |
| 83 | 83 | 'd_id' => $id, |
| 84 | 84 | ]), 'data', []); |
| 85 | - $this->_toArrayCall = function ($array) { |
|
| 85 | + $this->_toArrayCall = function($array) { |
|
| 86 | 86 | return Arrays::columns($array, [ |
| 87 | 87 | 'id' => 'd_id', |
| 88 | 88 | 'name' => 'd_name', |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | 'lang' => 'd_lang', |
| 94 | 94 | 'year' => 'd_year', |
| 95 | 95 | 'description' => 'd_content', |
| 96 | - 'episodes' => function ($array) { |
|
| 96 | + 'episodes' => function($array) { |
|
| 97 | 97 | $episodes = explode('#', I::get($array, 'd_playurl')); |
| 98 | 98 | return Arrays::explode('$', $episodes); |
| 99 | 99 | }, |