Completed
Pull Request — master (#2)
by lee
04:31
created
src/YahooWeatherAPI.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,6 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
tests/YahooWeatherClientTests.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -302,6 +302,9 @@
 block discarded – undo
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(
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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()
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.