@@ -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 | } |