@@ -211,7 +211,7 @@ |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * @param GoutteClient $client |
|
214 | + * @param Client $client |
|
215 | 215 | */ |
216 | 216 | public function setClient(Client $client) |
217 | 217 | { |
@@ -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 |
@@ -302,6 +302,9 @@ |
||
302 | 302 | return $service->getYql(); |
303 | 303 | } |
304 | 304 | |
305 | + /** |
|
306 | + * @param string $url |
|
307 | + */ |
|
305 | 308 | public function encodeURI($url) |
306 | 309 | { |
307 | 310 | $unescaped = array( |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $response = $service->callApiWoeid(null); |
34 | 34 | } |
35 | 35 | catch(\Exception $e) { |
36 | - throw $e; |
|
36 | + throw $e; |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $response = $service->callApiCityName(null); |
49 | 49 | } |
50 | 50 | catch(\Exception $e) { |
51 | - throw $e; |
|
51 | + throw $e; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $response = $service->callApi(null); |
64 | 64 | } |
65 | 65 | catch(\Exception $e) { |
66 | - throw $e; |
|
66 | + throw $e; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $response = $service->callApi($errYql); |
81 | 81 | } |
82 | 82 | catch(\Exception $e) { |
83 | - throw $e; |
|
83 | + throw $e; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 |
@@ -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() |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | try { |
33 | 33 | $response = $service->callApiWoeid(null); |
34 | - } |
|
35 | - catch(\Exception $e) { |
|
34 | + } catch(\Exception $e) { |
|
36 | 35 | throw $e; |
37 | 36 | } |
38 | 37 | } |
@@ -46,8 +45,7 @@ discard block |
||
46 | 45 | |
47 | 46 | try { |
48 | 47 | $response = $service->callApiCityName(null); |
49 | - } |
|
50 | - catch(\Exception $e) { |
|
48 | + } catch(\Exception $e) { |
|
51 | 49 | throw $e; |
52 | 50 | } |
53 | 51 | } |
@@ -61,8 +59,7 @@ discard block |
||
61 | 59 | |
62 | 60 | try { |
63 | 61 | $response = $service->callApi(null); |
64 | - } |
|
65 | - catch(\Exception $e) { |
|
62 | + } catch(\Exception $e) { |
|
66 | 63 | throw $e; |
67 | 64 | } |
68 | 65 | } |
@@ -78,8 +75,7 @@ discard block |
||
78 | 75 | |
79 | 76 | try { |
80 | 77 | $response = $service->callApi($errYql); |
81 | - } |
|
82 | - catch(\Exception $e) { |
|
78 | + } catch(\Exception $e) { |
|
83 | 79 | throw $e; |
84 | 80 | } |
85 | 81 | } |