Completed
Push — master ( 2996b3...2d8d08 )
by Francis
17s queued 10s
created
src/LiveStream/LiveStream.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
         $events = [];
237 237
 
238 238
         $response = $this->request("accounts/{$accountId}/{$type}_events", 'get', null, [
239
-          'page'     => $page,
240
-          'maxItems' => $maxItems,
241
-          'order'    => $order
239
+            'page'     => $page,
240
+            'maxItems' => $maxItems,
241
+            'order'    => $order
242 242
         ]);
243 243
 
244 244
         if ($response === null) return $events;
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
      * @throws \LiveStream\Exceptions\LiveStreamException
402 402
      */
403 403
     public function getLiveVideo(
404
-      int $accountId,
405
-      int $eventId,
404
+        int $accountId,
405
+        int $eventId,
406 406
       ?int $offsetPostId = null,
407 407
       ?int $older = null,
408 408
       ?int $newer = null
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
         $video = null;
411 411
 
412 412
         $response = $this->request("accounts/$accountId/events/$eventId/videos", 'get', null, [
413
-          'offsetPostId' => $offsetPostId,
414
-          'older'        => $older,
415
-          'newer'        => $newer
413
+            'offsetPostId' => $offsetPostId,
414
+            'older'        => $older,
415
+            'newer'        => $newer
416 416
         ]);
417 417
 
418 418
         if ($response === null) return null;
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 
443 443
         $token = $this->generateToken('playback');
444 444
         $query = [
445
-          'clientId' => $this->clientId,
446
-          'timestamp' => $token['timestamp'],
447
-          'token' => $token['token']
445
+            'clientId' => $this->clientId,
446
+            'timestamp' => $token['timestamp'],
447
+            'token' => $token['token']
448 448
         ];
449 449
         return $video->m3u8 . '?' . http_build_query($query);
450 450
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -474,7 +474,7 @@
 block discarded – undo
474 474
     private function refreshToken(): void
475 475
     {
476 476
         $now = round(microtime(true) * 1000);
477
-        if (!$this->tokenTimestamp || round(($now - $this->tokenTimestamp)/1000) > 300) {
477
+        if (!$this->tokenTimestamp || round(($now - $this->tokenTimestamp) / 1000) > 300) {
478 478
             $token = $this->generateToken();
479 479
             $this->tokenTimestamp = $token['timestamp'];
480 480
             $this->token = $token['token'];
Please login to merge, or discard this patch.
Braces   +58 added lines, -21 removed lines patch added patch discarded remove patch
@@ -124,7 +124,9 @@  discard block
 block discarded – undo
124 124
     public function getAccount(int $accountId): ?Account
125 125
     {
126 126
         $response = $this->request("accounts/$accountId");
127
-        if ($response === null) return null;
127
+        if ($response === null) {
128
+            return null;
129
+        }
128 130
 
129 131
         return Account::fromObject(json_decode($response));
130 132
     }
@@ -142,7 +144,9 @@  discard block
 block discarded – undo
142 144
 
143 145
         $response = $this->request("accounts/$accountId/events", 'post', $event);
144 146
 
145
-        if ($response === null) return false;
147
+        if ($response === null) {
148
+            return false;
149
+        }
146 150
 
147 151
         $event = Event::fromObject(json_decode($response));
148 152
 
@@ -162,7 +166,9 @@  discard block
 block discarded – undo
162 166
 
163 167
         $response = $this->request("accounts/$accountId/events/$event->id", 'put', $event);
164 168
 
165
-        if ($response === null) return false;
169
+        if ($response === null) {
170
+            return false;
171
+        }
166 172
 
167 173
         return true;
168 174
     }
@@ -179,7 +185,9 @@  discard block
 block discarded – undo
179 185
     {
180 186
         $response = $this->request("accounts/$accountId/events/$eventId", 'delete');
181 187
 
182
-        if ($response === null) return null;
188
+        if ($response === null) {
189
+            return null;
190
+        }
183 191
 
184 192
         return Event::fromObject(json_decode($response));
185 193
     }
@@ -207,7 +215,9 @@  discard block
 block discarded – undo
207 215
             'logo' => new CURLFile($filePath, mime_content_type($filePath), basename($filePath))
208 216
         ]);
209 217
 
210
-        if ($response == null) return null;
218
+        if ($response == null) {
219
+            return null;
220
+        }
211 221
 
212 222
         return Event::fromObject(json_decode($response));
213 223
     }
@@ -241,7 +251,9 @@  discard block
 block discarded – undo
241 251
           'order'    => $order
242 252
         ]);
243 253
 
244
-        if ($response === null) return $events;
254
+        if ($response === null) {
255
+            return $events;
256
+        }
245 257
 
246 258
         foreach (json_decode($response)->data as $event) {
247 259
             $events[] = Event::fromObject($event);
@@ -364,7 +376,9 @@  discard block
 block discarded – undo
364 376
             'saveVideo'       => $saveVideo
365 377
         ]);
366 378
 
367
-        if ($response === null) return null;
379
+        if ($response === null) {
380
+            return null;
381
+        }
368 382
 
369 383
         return RTMPKey::fromObject(json_decode($response));
370 384
     }
@@ -380,7 +394,9 @@  discard block
 block discarded – undo
380 394
     {
381 395
         $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put');
382 396
 
383
-        if ($response === null) return null;
397
+        if ($response === null) {
398
+            return null;
399
+        }
384 400
 
385 401
         return RTMPKey::fromObject(json_decode($response));
386 402
     }
@@ -415,7 +431,9 @@  discard block
 block discarded – undo
415 431
           'newer'        => $newer
416 432
         ]);
417 433
 
418
-        if ($response === null) return null;
434
+        if ($response === null) {
435
+            return null;
436
+        }
419 437
 
420 438
         $response_data = json_decode($response);
421 439
 
@@ -438,7 +456,9 @@  discard block
 block discarded – undo
438 456
      * @return string|null
439 457
      */
440 458
     public function getVideoHlsFileUrl(Video $video): ?string {
441
-        if (!$video->m3u8) return null;
459
+        if (!$video->m3u8) {
460
+            return null;
461
+        }
442 462
 
443 463
         $token = $this->generateToken('playback');
444 464
         $query = [
@@ -460,7 +480,9 @@  discard block
 block discarded – undo
460 480
      * @throws \LiveStream\Exceptions\LiveStreamException
461 481
      */
462 482
     public function getVideoHlsFileContents(Video $video): ?string {
463
-        if (!$video->m3u8) return null;
483
+        if (!$video->m3u8) {
484
+            return null;
485
+        }
464 486
 
465 487
         $endpoint = substr($video->m3u8, strlen(self::BASE_URL));
466 488
         return $this->request($endpoint);
@@ -521,7 +543,9 @@  discard block
 block discarded – undo
521 543
     ): ?string {
522 544
         $ch = curl_init();
523 545
 
524
-        if (!$ch) throw new Exception("Could not initialize CURL.");
546
+        if (!$ch) {
547
+            throw new Exception("Could not initialize CURL.");
548
+        }
525 549
 
526 550
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
527 551
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@@ -531,8 +555,7 @@  discard block
 block discarded – undo
531 555
             $query['timestamp'] = $this->tokenTimestamp;
532 556
             $query['clientId'] = $this->clientId;
533 557
             $query['token'] = $this->token;
534
-        }
535
-        else {
558
+        } else {
536 559
             curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey . ':');
537 560
         }
538 561
 
@@ -543,9 +566,15 @@  discard block
 block discarded – undo
543 566
         );
544 567
 
545 568
         if ($verb != 'get') {
546
-            if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true);
547
-            if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
548
-            if ($verb == 'delete') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
569
+            if ($verb == 'post') {
570
+                curl_setopt($ch, CURLOPT_POST, true);
571
+            }
572
+            if ($verb == 'put') {
573
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
574
+            }
575
+            if ($verb == 'delete') {
576
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
577
+            }
549 578
             if ($body) {
550 579
                 curl_setopt($ch, CURLOPT_HTTPHEADER, [
551 580
                     'Content-Type: ' . $body->getContentType()
@@ -564,13 +593,21 @@  discard block
 block discarded – undo
564 593
 
565 594
         curl_close($ch);
566 595
 
567
-        if ($code == 200 || $code == 201) return $response;
596
+        if ($code == 200 || $code == 201) {
597
+            return $response;
598
+        }
568 599
 
569
-        if ($code == 404) return null;
600
+        if ($code == 404) {
601
+            return null;
602
+        }
570 603
 
571
-        if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred.");
604
+        if ($code <= 199) {
605
+            throw new Exception("A CURL erorr with code '$code', has occurred.");
606
+        }
572 607
 
573
-        if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
608
+        if ($code == 403) {
609
+            throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
610
+        }
574 611
 
575 612
         throw new LiveStreamException(self::ERROR_CODES[$code]);
576 613
     }
Please login to merge, or discard this patch.