@@ -18,7 +18,7 @@ |
||
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 | /** |
@@ -18,8 +18,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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)'); |
@@ -21,7 +21,9 @@ discard block |
||
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 |
||
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; |
@@ -77,7 +77,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
170 | 178 | 'order' => $order |
171 | 179 | ]); |
172 | 180 | |
173 | - if ($response === null) return null; |
|
181 | + if ($response === null) { |
|
182 | + return null; |
|
183 | + } |
|
174 | 184 | |
175 | 185 | $events = []; |
176 | 186 | |
@@ -203,7 +213,9 @@ discard block |
||
203 | 213 | 'saveVideo' => $saveVideo |
204 | 214 | ]); |
205 | 215 | |
206 | - if ($response === null) return null; |
|
216 | + if ($response === null) { |
|
217 | + return null; |
|
218 | + } |
|
207 | 219 | |
208 | 220 | return RTMPKey::fromObject(json_decode($response)); |
209 | 221 | } |
@@ -219,7 +231,9 @@ discard block |
||
219 | 231 | { |
220 | 232 | $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put'); |
221 | 233 | |
222 | - if ($response === null) return null; |
|
234 | + if ($response === null) { |
|
235 | + return null; |
|
236 | + } |
|
223 | 237 | |
224 | 238 | return RTMPKey::fromObject(json_decode($response)); |
225 | 239 | } |
@@ -239,7 +253,9 @@ discard block |
||
239 | 253 | ): ?string { |
240 | 254 | $ch = curl_init(); |
241 | 255 | |
242 | - if (!$ch) throw new Exception("Could not initialize CURL."); |
|
256 | + if (!$ch) { |
|
257 | + throw new Exception("Could not initialize CURL."); |
|
258 | + } |
|
243 | 259 | |
244 | 260 | curl_setopt( |
245 | 261 | $ch, |
@@ -251,8 +267,12 @@ discard block |
||
251 | 267 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
252 | 268 | |
253 | 269 | if ($verb != 'get') { |
254 | - if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true); |
|
255 | - if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
270 | + if ($verb == 'post') { |
|
271 | + curl_setopt($ch, CURLOPT_POST, true); |
|
272 | + } |
|
273 | + if ($verb == 'put') { |
|
274 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
275 | + } |
|
256 | 276 | if ($body) { |
257 | 277 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
258 | 278 | 'Content-Type: ' . $body->getContentType() |
@@ -271,13 +291,21 @@ discard block |
||
271 | 291 | |
272 | 292 | curl_close($ch); |
273 | 293 | |
274 | - if ($code == 200 || $code == 201) return $response; |
|
294 | + if ($code == 200 || $code == 201) { |
|
295 | + return $response; |
|
296 | + } |
|
275 | 297 | |
276 | - if ($code == 404) return null; |
|
298 | + if ($code == 404) { |
|
299 | + return null; |
|
300 | + } |
|
277 | 301 | |
278 | - if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
302 | + if ($code <= 199) { |
|
303 | + throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
304 | + } |
|
279 | 305 | |
280 | - if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
306 | + if ($code == 403) { |
|
307 | + throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
308 | + } |
|
281 | 309 | |
282 | 310 | throw new LiveStreamException(self::ERROR_CODES[$code]); |
283 | 311 | } |