Passed
Push — master ( 4c0885...a98b66 )
by Francis
01:35
created
src/LiveStream/Resources/Event.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     {
19 19
         parent::__construct($init);
20 20
         if ($init)
21
-            $this->data->fullName  = $fullName;
21
+            $this->data->fullName = $fullName;
22 22
     }
23 23
 
24 24
     /**
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
     public function __construct(string $fullName, bool $init = true)
19 19
     {
20 20
         parent::__construct($init);
21
-        if ($init)
22
-            $this->data->fullName  = $fullName;
21
+        if ($init) {
22
+                    $this->data->fullName  = $fullName;
23
+        }
23 24
     }
24 25
 
25 26
     /**
@@ -77,7 +78,9 @@  discard block
 block discarded – undo
77 78
      */
78 79
     public function addTag(string $tag): Event
79 80
     {
80
-        if (!isset($this->data->tags)) $this->data->tags = '';
81
+        if (!isset($this->data->tags)) {
82
+            $this->data->tags = '';
83
+        }
81 84
 
82 85
         $this->data->tags .= rtrim($tag, ',') . ',';
83 86
 
@@ -156,8 +159,9 @@  discard block
 block discarded – undo
156 159
     private function set_fields(array &$array, array $map): void
157 160
     {
158 161
         foreach ($map as $key => $value) {
159
-            if ($value)
160
-                $array[$key] = $value;
162
+            if ($value) {
163
+                            $array[$key] = $value;
164
+            }
161 165
         }
162 166
     }
163 167
 
@@ -180,7 +184,9 @@  discard block
 block discarded – undo
180 184
      */
181 185
     public function validate(bool $exists = false): void
182 186
     {
183
-        if (!$this->data->fullName ?? null) throw new InValidResourceException('Event', 'fullName');
187
+        if (!$this->data->fullName ?? null) {
188
+            throw new InValidResourceException('Event', 'fullName');
189
+        }
184 190
 
185 191
         if (($this->data->isPasswordProtected ?? false) && (!$this->data->password ?? null)) {
186 192
             throw new InValidResourceException('Event', 'password (password must be present for a password protected event)');
Please login to merge, or discard this patch.
src/LiveStream/Resources/Resource.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function __construct(bool $init = true)
23 23
     {
24
-        if ($init) $this->data = new stdClass();
24
+        if ($init) {
25
+            $this->data = new stdClass();
26
+        }
25 27
     }
26 28
 
27 29
     /**
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
      */
33 35
     public static function fromObject(object $object): Resource
34 36
     {
35
-        if ($object == null) return null;
37
+        if ($object == null) {
38
+            return null;
39
+        }
36 40
 
37 41
         $instance = new static(false);
38 42
         $instance->data = $object;
Please login to merge, or discard this patch.
src/LiveStream/LiveStream.php 1 patch
Braces   +48 added lines, -16 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
     }
@@ -132,7 +138,9 @@  discard block
 block discarded – undo
132 138
     {
133 139
         $response = $this->request("accounts/$accountId/events/$eventId", 'delete');
134 140
 
135
-        if ($response === null) return null;
141
+        if ($response === null) {
142
+            return null;
143
+        }
136 144
 
137 145
         return Event::fromObject(json_decode($response));
138 146
     }
@@ -160,7 +168,9 @@  discard block
 block discarded – undo
160 168
             'logo' => new CURLFile($filePath, mime_content_type($filePath), basename($filePath))
161 169
         ]);
162 170
 
163
-        if ($response == null) return null;
171
+        if ($response == null) {
172
+            return null;
173
+        }
164 174
 
165 175
         return Event::fromObject(json_decode($response));
166 176
     }
@@ -187,7 +197,9 @@  discard block
 block discarded – undo
187 197
             'order'    => $order
188 198
         ]);
189 199
 
190
-        if ($response === null) return null;
200
+        if ($response === null) {
201
+            return null;
202
+        }
191 203
 
192 204
         $events = [];
193 205
 
@@ -220,7 +232,9 @@  discard block
 block discarded – undo
220 232
             'saveVideo'       => $saveVideo
221 233
         ]);
222 234
 
223
-        if ($response === null) return null;
235
+        if ($response === null) {
236
+            return null;
237
+        }
224 238
 
225 239
         return RTMPKey::fromObject(json_decode($response));
226 240
     }
@@ -236,7 +250,9 @@  discard block
 block discarded – undo
236 250
     {
237 251
         $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put');
238 252
 
239
-        if ($response === null) return null;
253
+        if ($response === null) {
254
+            return null;
255
+        }
240 256
 
241 257
         return RTMPKey::fromObject(json_decode($response));
242 258
     }
@@ -256,7 +272,9 @@  discard block
 block discarded – undo
256 272
     ): ?string {
257 273
         $ch = curl_init();
258 274
 
259
-        if (!$ch) throw new Exception("Could not initialize CURL.");
275
+        if (!$ch) {
276
+            throw new Exception("Could not initialize CURL.");
277
+        }
260 278
 
261 279
         curl_setopt(
262 280
             $ch,
@@ -268,9 +286,15 @@  discard block
 block discarded – undo
268 286
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
269 287
 
270 288
         if ($verb != 'get') {
271
-            if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true);
272
-            if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
273
-            if ($verb == 'delete') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
289
+            if ($verb == 'post') {
290
+                curl_setopt($ch, CURLOPT_POST, true);
291
+            }
292
+            if ($verb == 'put') {
293
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
294
+            }
295
+            if ($verb == 'delete') {
296
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
297
+            }
274 298
             if ($body) {
275 299
                 curl_setopt($ch, CURLOPT_HTTPHEADER, [
276 300
                     'Content-Type: ' . $body->getContentType()
@@ -289,13 +313,21 @@  discard block
 block discarded – undo
289 313
 
290 314
         curl_close($ch);
291 315
 
292
-        if ($code == 200 || $code == 201) return $response;
316
+        if ($code == 200 || $code == 201) {
317
+            return $response;
318
+        }
293 319
 
294
-        if ($code == 404) return null;
320
+        if ($code == 404) {
321
+            return null;
322
+        }
295 323
 
296
-        if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred.");
324
+        if ($code <= 199) {
325
+            throw new Exception("A CURL erorr with code '$code', has occurred.");
326
+        }
297 327
 
298
-        if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
328
+        if ($code == 403) {
329
+            throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
330
+        }
299 331
 
300 332
         throw new LiveStreamException(self::ERROR_CODES[$code]);
301 333
     }
Please login to merge, or discard this patch.