Passed
Push — master ( d91ec9...05758d )
by Francis
02:05
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   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -76,7 +76,9 @@  discard block
 block discarded – undo
76 76
     public function getAccount(int $accountId): ?Account
77 77
     {
78 78
         $response = $this->request("accounts/$accountId");
79
-        if ($response === null) return null;
79
+        if ($response === null) {
80
+            return null;
81
+        }
80 82
 
81 83
         return Account::fromObject(json_decode($response));
82 84
     }
@@ -94,7 +96,9 @@  discard block
 block discarded – undo
94 96
 
95 97
         $response = $this->request("accounts/$accountId/events", 'post', $event);
96 98
 
97
-        if ($response === null) return false;
99
+        if ($response === null) {
100
+            return false;
101
+        }
98 102
 
99 103
         $event = Event::fromObject(json_decode($response));
100 104
 
@@ -114,7 +118,9 @@  discard block
 block discarded – undo
114 118
 
115 119
         $response = $this->request("accounts/$accountId/events/$event->id", 'put', $event);
116 120
 
117
-        if ($response === null) return false;
121
+        if ($response === null) {
122
+            return false;
123
+        }
118 124
 
119 125
         return true;
120 126
     }
@@ -141,7 +147,9 @@  discard block
 block discarded – undo
141 147
             'saveVideo'       => $saveVideo
142 148
         ]);
143 149
 
144
-        if ($response === null) return null;
150
+        if ($response === null) {
151
+            return null;
152
+        }
145 153
 
146 154
         return RTMPKey::fromObject(json_decode($response));
147 155
     }
@@ -157,7 +165,9 @@  discard block
 block discarded – undo
157 165
     {
158 166
         $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put');
159 167
 
160
-        if ($response === null) return null;
168
+        if ($response === null) {
169
+            return null;
170
+        }
161 171
 
162 172
         return RTMPKey::fromObject(json_decode($response));
163 173
     }
@@ -176,7 +186,9 @@  discard block
 block discarded – undo
176 186
     ): ?string {
177 187
         $ch = curl_init();
178 188
 
179
-        if (!$ch) throw new Exception("Could not initialize CURL.");
189
+        if (!$ch) {
190
+            throw new Exception("Could not initialize CURL.");
191
+        }
180 192
 
181 193
         curl_setopt(
182 194
             $ch,
@@ -188,8 +200,12 @@  discard block
 block discarded – undo
188 200
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
189 201
 
190 202
         if ($verb != 'get') {
191
-            if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true);
192
-            if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
203
+            if ($verb == 'post') {
204
+                curl_setopt($ch, CURLOPT_POST, true);
205
+            }
206
+            if ($verb == 'put') {
207
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
208
+            }
193 209
             if ($body) {
194 210
                 curl_setopt($ch, CURLOPT_HTTPHEADER, [
195 211
                     'Content-Type: ' . $body->getContentType()
@@ -203,13 +219,21 @@  discard block
 block discarded – undo
203 219
 
204 220
         curl_close($ch);
205 221
 
206
-        if ($code == 200 || $code == 201) return $response;
222
+        if ($code == 200 || $code == 201) {
223
+            return $response;
224
+        }
207 225
 
208
-        if ($code == 404) return null;
226
+        if ($code == 404) {
227
+            return null;
228
+        }
209 229
 
210
-        if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred.");
230
+        if ($code <= 199) {
231
+            throw new Exception("A CURL erorr with code '$code', has occurred.");
232
+        }
211 233
 
212
-        if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
234
+        if ($code == 403) {
235
+            throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message);
236
+        }
213 237
 
214 238
         throw new LiveStreamException(self::ERROR_CODES[$code]);
215 239
     }
Please login to merge, or discard this patch.