@@ -10,8 +10,6 @@ |
||
10 | 10 | |
11 | 11 | namespace Th3Mouk\YahooWeatherAPI; |
12 | 12 | |
13 | -use Psr\Http\Message\ServerRequestInterface as Request; |
|
14 | -use Psr\Http\Message\ResponseInterface as Response; |
|
15 | 13 | use GuzzleHttp\Client; |
16 | 14 | use Th3Mouk\YahooWeatherAPI\Query\Query; |
17 | 15 |
@@ -107,7 +107,7 @@ |
||
107 | 107 | } else { |
108 | 108 | $this->lastResponse = $response['query']['results']['channel']; |
109 | 109 | } |
110 | - } catch(\Exception $e) { |
|
110 | + } catch (\Exception $e) { |
|
111 | 111 | throw new \Exception("Something error happen, please check your request url whether it's correct.", 400); |
112 | 112 | } |
113 | 113 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | try { |
33 | 33 | $response = $service->callApiWoeid(null); |
34 | 34 | } |
35 | - catch(\Exception $e) { |
|
35 | + catch (\Exception $e) { |
|
36 | 36 | throw $e; |
37 | 37 | } |
38 | 38 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | try { |
48 | 48 | $response = $service->callApiCityName(null); |
49 | 49 | } |
50 | - catch(\Exception $e) { |
|
50 | + catch (\Exception $e) { |
|
51 | 51 | throw $e; |
52 | 52 | } |
53 | 53 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | try { |
63 | 63 | $response = $service->callApi(null); |
64 | 64 | } |
65 | - catch(\Exception $e) { |
|
65 | + catch (\Exception $e) { |
|
66 | 66 | throw $e; |
67 | 67 | } |
68 | 68 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | try { |
80 | 80 | $response = $service->callApi($errYql); |
81 | 81 | } |
82 | - catch(\Exception $e) { |
|
82 | + catch (\Exception $e) { |
|
83 | 83 | throw $e; |
84 | 84 | } |
85 | 85 | } |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | { |
144 | 144 | $service = new YahooWeatherAPI(); |
145 | 145 | $yql = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="123456789")'; |
146 | - $url = "https://query.yahooapis.com/v1/public/yql?q=" . $yql . "&format=json&env=store://datatables.org/alltableswithkeys"; |
|
146 | + $url = "https://query.yahooapis.com/v1/public/yql?q=".$yql."&format=json&env=store://datatables.org/alltableswithkeys"; |
|
147 | 147 | $url = $this->encodeURI($url); |
148 | 148 | $response = $service->callApi($url); |
149 | 149 | $this->assertSame($response, false); |
150 | 150 | |
151 | 151 | $yql = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="Taipei")'; |
152 | - $url = "https://query.yahooapis.com/v1/public/yql?q=" . $yql . "&format=json&env=store://datatables.org/alltableswithkeys"; |
|
152 | + $url = "https://query.yahooapis.com/v1/public/yql?q=".$yql."&format=json&env=store://datatables.org/alltableswithkeys"; |
|
153 | 153 | $url = $this->encodeURI($url); |
154 | 154 | $response = $service->callApi($url); |
155 | 155 | $city = str_replace(" ", "", $response["location"]["city"]); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->assertSame(is_string($response), true); |
201 | 201 | |
202 | 202 | $response = $service->getTemperature(false); |
203 | - $this->assertSame(is_string((int)$response), false); |
|
203 | + $this->assertSame(is_string((int) $response), false); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** @test */ |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | ); |
275 | 275 | |
276 | 276 | $response = $service->getWind(true); |
277 | - $expectRes['speed'] .= ' ' . $storeRes['units']['speed']; |
|
277 | + $expectRes['speed'] .= ' '.$storeRes['units']['speed']; |
|
278 | 278 | $this->assertSame($response['speed'], $expectRes['speed']); |
279 | 279 | |
280 | 280 | $expectRes = array( |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | public function encodeURI($url) |
306 | 306 | { |
307 | 307 | $unescaped = array( |
308 | - '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~', |
|
308 | + '%2D'=>'-', '%5F'=>'_', '%2E'=>'.', '%21'=>'!', '%7E'=>'~', |
|
309 | 309 | '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')' |
310 | 310 | ); |
311 | 311 | $reserved = array( |
312 | - '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':', |
|
313 | - '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$' |
|
312 | + '%3B'=>';', '%2C'=>',', '%2F'=>'/', '%3F'=>'?', '%3A'=>':', |
|
313 | + '%40'=>'@', '%26'=>'&', '%3D'=>'=', '%2B'=>'+', '%24'=>'$' |
|
314 | 314 | ); |
315 | 315 | $score = array( |
316 | 316 | '%23'=>'#' |
317 | 317 | ); |
318 | - return strtr(rawurlencode($url), array_merge($reserved,$unescaped,$score)); |
|
318 | + return strtr(rawurlencode($url), array_merge($reserved, $unescaped, $score)); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | public function getResponseData() |