Passed
Push — master ( 9ff61e...68c176 )
by Francis
01:55
created
src/LiveStream/LiveStream.php 1 patch
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -77,7 +77,9 @@  discard block
 block discarded – undo
77 77
     public function getAccount(int $accountId): ?Account
78 78
     {
79 79
         $response = $this->request("accounts/$accountId");
80
-        if ($response === null) return null;
80
+        if ($response === null) {
81
+            return null;
82
+        }
81 83
 
82 84
         return Account::fromObject(json_decode($response));
83 85
     }
@@ -95,7 +97,9 @@  discard block
 block discarded – undo
95 97
 
96 98
         $response = $this->request("accounts/$accountId/events", 'post', $event);
97 99
 
98
-        if ($response === null) return false;
100
+        if ($response === null) {
101
+            return false;
102
+        }
99 103
 
100 104
         $event = Event::fromObject(json_decode($response));
101 105
 
@@ -115,7 +119,9 @@  discard block
 block discarded – undo
115 119
 
116 120
         $response = $this->request("accounts/$accountId/events/$event->id", 'put', $event);
117 121
 
118
-        if ($response === null) return false;
122
+        if ($response === null) {
123
+            return false;
124
+        }
119 125
 
120 126
         return true;
121 127
     }
@@ -143,7 +149,9 @@  discard block
 block discarded – undo
143 149
             'logo' => new CURLFile($filePath, mime_content_type($filePath), basename($filePath))
144 150
         ]);
145 151
 
146
-        if ($response == null) return null;
152
+        if ($response == null) {
153
+            return null;
154
+        }
147 155
 
148 156
         return Event::fromObject(json_decode($response));
149 157
     }
@@ -170,7 +178,9 @@  discard block
 block discarded – undo
170 178
             'saveVideo'       => $saveVideo
171 179
         ]);
172 180
 
173
-        if ($response === null) return null;
181
+        if ($response === null) {
182
+            return null;
183
+        }
174 184
 
175 185
         return RTMPKey::fromObject(json_decode($response));
176 186
     }
@@ -186,7 +196,9 @@  discard block
 block discarded – undo
186 196
     {
187 197
         $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put');
188 198
 
189
-        if ($response === null) return null;
199
+        if ($response === null) {
200
+            return null;
201
+        }
190 202
 
191 203
         return RTMPKey::fromObject(json_decode($response));
192 204
     }
@@ -206,7 +218,9 @@  discard block
 block discarded – undo
206 218
     ): ?string {
207 219
         $ch = curl_init();
208 220
 
209
-        if (!$ch) throw new Exception("Could not initialize CURL.");
221
+        if (!$ch) {
222
+            throw new Exception("Could not initialize CURL.");
223
+        }
210 224
 
211 225
         curl_setopt(
212 226
             $ch,
@@ -218,8 +232,12 @@  discard block
 block discarded – undo
218 232
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
219 233
 
220 234
         if ($verb != 'get') {
221
-            if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true);
222
-            if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
235
+            if ($verb == 'post') {
236
+                curl_setopt($ch, CURLOPT_POST, true);
237
+            }
238
+            if ($verb == 'put') {
239
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
240
+            }
223 241
             if ($body) {
224 242
                 curl_setopt($ch, CURLOPT_HTTPHEADER, [
225 243
                     'Content-Type: ' . $body->getContentType()
@@ -238,13 +256,21 @@  discard block
 block discarded – undo
238 256
 
239 257
         curl_close($ch);
240 258
 
241
-        if ($code == 200 || $code == 201) return $response;
259
+        if ($code == 200 || $code == 201) {
260
+            return $response;
261
+        }
242 262
 
243
-        if ($code == 404) return null;
263
+        if ($code == 404) {
264
+            return null;
265
+        }
244 266
 
245
-        if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred.");
267
+        if ($code <= 199) {
268
+            throw new Exception("A CURL erorr with code '$code', has occurred.");
269
+        }
246 270
 
247
-        if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
271
+        if ($code == 403) {
272
+            throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
273
+        }
248 274
 
249 275
         throw new LiveStreamException(self::ERROR_CODES[$code]);
250 276
     }
Please login to merge, or discard this patch.