Passed
Branch account (184271)
by vincent
02:51
created
src/VfacTmdb/Tmdb.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -161,7 +161,8 @@  discard block
 block discarded – undo
161 161
      */
162 162
     protected function sendRequest(string $method, string $url, array $form_params = array()) : ?\stdClass
163 163
     {
164
-        switch ($method) {
164
+        switch ($method)
165
+        {
165 166
               case 'GET':
166 167
                   $res = $this->http_request->getResponse($url);
167 168
                   break;
@@ -179,7 +180,8 @@  discard block
 block discarded – undo
179 180
             throw new ServerErrorException();
180 181
         }
181 182
         $response = json_decode($res->getBody());
182
-        if (empty($response)) {
183
+        if (empty($response))
184
+        {
183 185
             $this->logger->error('Request Body can not be decode', array('method' => $method, 'url' => $url, 'form_params' => $form_params));
184 186
             throw new ServerErrorException();
185 187
         }
@@ -216,14 +218,18 @@  discard block
 block discarded – undo
216 218
      */
217 219
     public function getConfiguration() : \stdClass
218 220
     {
219
-        try {
221
+        try
222
+        {
220 223
             $this->logger->debug('Start getting configuration');
221
-            if (is_null($this->configuration)) {
224
+            if (is_null($this->configuration))
225
+            {
222 226
                 $this->logger->debug('No configuration found, sending HTTP request to get it');
223 227
                 $this->configuration = $this->getRequest('configuration');
224 228
             }
225 229
             return $this->configuration;
226
-        } catch (TmdbException $ex) {
230
+        }
231
+        catch (TmdbException $ex)
232
+        {
227 233
             throw $ex;
228 234
         }
229 235
     }
@@ -242,8 +248,10 @@  discard block
 block discarded – undo
242 248
         // $params['include_adult'] = $this->include_adult;
243 249
         // $params['page']          = $this->page;
244 250
         // Check options
245
-        foreach ($options as $key => $value) {
246
-            switch ($key) {
251
+        foreach ($options as $key => $value)
252
+        {
253
+            switch ($key)
254
+            {
247 255
                 case 'year':
248 256
                     $params[$key] = $this->checkYear($value);
249 257
                     break;
@@ -291,7 +299,8 @@  discard block
 block discarded – undo
291 299
     private function checkLanguage(string $language) : string
292 300
     {
293 301
         $check = preg_match("#([a-z]{2})-([A-Z]{2})#", $language);
294
-        if ($check === 0 || $check === false) {
302
+        if ($check === 0 || $check === false)
303
+        {
295 304
             $this->logger->error('Incorrect language param option', array('language' => $language));
296 305
             throw new IncorrectParamException;
297 306
         }
@@ -306,7 +315,8 @@  discard block
 block discarded – undo
306 315
      */
307 316
     private function checkSort(string $direction) : string
308 317
     {
309
-        switch ($direction) {
318
+        switch ($direction)
319
+        {
310 320
             case 'asc':
311 321
             case 'desc':
312 322
                 break;
@@ -332,7 +342,8 @@  discard block
 block discarded – undo
332 342
      */
333 343
     public function __get(string $name) : string
334 344
     {
335
-        switch ($name) {
345
+        switch ($name)
346
+        {
336 347
             case 'url':
337 348
                 return $this->$name;
338 349
             default:
Please login to merge, or discard this patch.
src/VfacTmdb/Auth.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -74,8 +74,10 @@  discard block
 block discarded – undo
74 74
     public function connect(string $request_token, ?string $redirect_url = null) : bool
75 75
     {
76 76
         $url = "https://www.themoviedb.org/authenticate/$request_token";
77
-        if (!is_null($redirect_url)) {
78
-            if (!filter_var($redirect_url, FILTER_VALIDATE_URL)) {
77
+        if (!is_null($redirect_url))
78
+        {
79
+            if (!filter_var($redirect_url, FILTER_VALIDATE_URL))
80
+            {
79 81
                 throw new IncorrectParamException('Invalid redirect Url');
80 82
             }
81 83
             $url .= "?redirect_to=$redirect_url";
@@ -92,7 +94,8 @@  discard block
 block discarded – undo
92 94
     {
93 95
         $data = $this->tmdb->getRequest('authentication/token/new', []);
94 96
 
95
-        if (!isset($data->success) || $data->success != 'true' || !isset($data->request_token)) {
97
+        if (!isset($data->success) || $data->success != 'true' || !isset($data->request_token))
98
+        {
96 99
             throw new InvalidResponseException("Getting request token failed");
97 100
         }
98 101
         $this->request_token            = $data->request_token;
@@ -110,7 +113,8 @@  discard block
 block discarded – undo
110 113
     {
111 114
         $data = $this->tmdb->getRequest('authentication/session/new', ['request_token' => $request_token]);
112 115
 
113
-        if (!isset($data->success) || $data->success != 'true' || !isset($data->session_id)) {
116
+        if (!isset($data->success) || $data->success != 'true' || !isset($data->session_id))
117
+        {
114 118
             throw new InvalidResponseException("Creating session failed");
115 119
         }
116 120
         $this->session_id = $data->session_id;
@@ -124,7 +128,8 @@  discard block
 block discarded – undo
124 128
      */
125 129
     public function __get(string $name)
126 130
     {
127
-        switch ($name) {
131
+        switch ($name)
132
+        {
128 133
           case 'request_token':
129 134
           case 'session_id':
130 135
               return $this->$name;
Please login to merge, or discard this patch.
src/VfacTmdb/lib/Guzzle/Client.php 1 patch
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,18 +54,23 @@
 block discarded – undo
54 54
      */
55 55
     private function sendResponse(string $method, string $url, array $options = [], array $form_params = array())
56 56
     {
57
-        try {
57
+        try
58
+        {
58 59
             $params = array_merge($options, [
59 60
                 'headers' => ['Content-Type' => 'application/json;charset=utf-8'],
60 61
                 'body' => json_encode($form_params)
61 62
             ]);
62 63
 
63 64
             return $this->guzzleClient->request($method, $url, $params);
64
-        } catch (RequestException $e) {
65
-            if (is_null($e->getResponse())) {
65
+        }
66
+        catch (RequestException $e)
67
+        {
68
+            if (is_null($e->getResponse()))
69
+            {
66 70
                 throw new HttpErrorException;
67 71
             }
68
-            switch ((int) $e->getResponse()->getStatusCode()) {
72
+            switch ((int) $e->getResponse()->getStatusCode())
73
+            {
69 74
                 case 404:
70 75
                     throw new NotFoundException($e->getMessage());
71 76
                 default:
Please login to merge, or discard this patch.
src/VfacTmdb/Account/Rated.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -149,14 +149,17 @@  discard block
 block discarded – undo
149 149
      */
150 150
     private function addRate(string $action, float $rate) : Rated
151 151
     {
152
-        try {
152
+        try
153
+        {
153 154
             $params = [];
154 155
             $params['value'] = $rate;
155 156
 
156 157
             $this->tmdb->postRequest($action, $this->options, $params);
157 158
 
158 159
             return $this;
159
-        } catch (TmdbException $e) {
160
+        }
161
+        catch (TmdbException $e)
162
+        {
160 163
             throw $e;
161 164
         }
162 165
     }
@@ -168,11 +171,14 @@  discard block
 block discarded – undo
168 171
      */
169 172
     private function removeRate(string $action) : Rated
170 173
     {
171
-        try {
174
+        try
175
+        {
172 176
             $this->tmdb->deleteRequest($action, $this->options);
173 177
 
174 178
             return $this;
175
-        } catch (TmdbException $e) {
179
+        }
180
+        catch (TmdbException $e)
181
+        {
176 182
             throw $e;
177 183
         }
178 184
     }
Please login to merge, or discard this patch.
src/VfacTmdb/Account/WatchList.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     private function setWatchlistItem(string $media_type, int $media_id, bool $watchlist) : WatchList
70 70
     {
71
-        try {
71
+        try
72
+        {
72 73
             $params               = [];
73 74
             $params['media_type'] = $media_type;
74 75
             $params['media_id']   = $media_id;
@@ -77,7 +78,9 @@  discard block
 block discarded – undo
77 78
             $this->tmdb->postRequest('account/'.$this->account_id.'/watchlist', $this->options, $params);
78 79
 
79 80
             return $this;
80
-        } catch (TmdbException $e) {
81
+        }
82
+        catch (TmdbException $e)
83
+        {
81 84
             throw $e;
82 85
         }
83 86
     }
Please login to merge, or discard this patch.
src/VfacTmdb/Account/Favorite.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     private function markAsFavorite(string  $media_type, int $media_id, bool $favorite) : Favorite
58 58
     {
59
-        try {
59
+        try
60
+        {
60 61
             $params               = [];
61 62
             $params['media_type'] = $media_type;
62 63
             $params['media_id']   = $media_id;
@@ -65,7 +66,9 @@  discard block
 block discarded – undo
65 66
             $this->tmdb->postRequest('account/'.$this->account_id.'/favorite', $this->options, $params);
66 67
 
67 68
             return $this;
68
-        } catch (TmdbException $e) {
69
+        }
70
+        catch (TmdbException $e)
71
+        {
69 72
             throw $e;
70 73
         }
71 74
     }
Please login to merge, or discard this patch.
src/VfacTmdb/Abstracts/Account.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,8 @@
 block discarded – undo
80 80
     protected function searchItemGenerator(array $results, string $class) : \Generator
81 81
     {
82 82
         $this->logger->debug('Starting search item generator', array('results' => $results, 'class' => $class));
83
-        foreach ($results as $result) {
83
+        foreach ($results as $result)
84
+        {
84 85
             $element = new $class($this->tmdb, $result);
85 86
 
86 87
             yield $element;
Please login to merge, or discard this patch.
src/VfacTmdb/Account.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,8 @@
 block discarded – undo
68 68
 
69 69
         // Get details account
70 70
         $this->data       = $this->tmdb->getRequest('account', array('session_id' => $this->session_id));
71
-        if (!isset($this->data->id)) {
71
+        if (!isset($this->data->id))
72
+        {
72 73
             throw new ServerErrorException('Invalid response for details account');
73 74
         }
74 75
         $this->account_id = $this->data->id;
Please login to merge, or discard this patch.