@@ -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 | 'saveVideo' => $saveVideo |
| 171 | 179 | ]); |
| 172 | 180 | |
| 173 | - if ($response === null) return null; |
|
| 181 | + if ($response === null) { |
|
| 182 | + return null; |
|
| 183 | + } |
|
| 174 | 184 | |
| 175 | 185 | return RTMPKey::fromObject(json_decode($response)); |
| 176 | 186 | } |
@@ -186,7 +196,9 @@ discard block |
||
| 186 | 196 | { |
| 187 | 197 | $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put'); |
| 188 | 198 | |
| 189 | - if ($response === null) return null; |
|
| 199 | + if ($response === null) { |
|
| 200 | + return null; |
|
| 201 | + } |
|
| 190 | 202 | |
| 191 | 203 | return RTMPKey::fromObject(json_decode($response)); |
| 192 | 204 | } |
@@ -206,7 +218,9 @@ discard block |
||
| 206 | 218 | ): ?string { |
| 207 | 219 | $ch = curl_init(); |
| 208 | 220 | |
| 209 | - if (!$ch) throw new Exception("Could not initialize CURL."); |
|
| 221 | + if (!$ch) { |
|
| 222 | + throw new Exception("Could not initialize CURL."); |
|
| 223 | + } |
|
| 210 | 224 | |
| 211 | 225 | curl_setopt( |
| 212 | 226 | $ch, |
@@ -218,8 +232,12 @@ discard block |
||
| 218 | 232 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 219 | 233 | |
| 220 | 234 | if ($verb != 'get') { |
| 221 | - if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true); |
|
| 222 | - if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 235 | + if ($verb == 'post') { |
|
| 236 | + curl_setopt($ch, CURLOPT_POST, true); |
|
| 237 | + } |
|
| 238 | + if ($verb == 'put') { |
|
| 239 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
| 240 | + } |
|
| 223 | 241 | if ($body) { |
| 224 | 242 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
| 225 | 243 | 'Content-Type: ' . $body->getContentType() |
@@ -238,13 +256,21 @@ discard block |
||
| 238 | 256 | |
| 239 | 257 | curl_close($ch); |
| 240 | 258 | |
| 241 | - if ($code == 200 || $code == 201) return $response; |
|
| 259 | + if ($code == 200 || $code == 201) { |
|
| 260 | + return $response; |
|
| 261 | + } |
|
| 242 | 262 | |
| 243 | - if ($code == 404) return null; |
|
| 263 | + if ($code == 404) { |
|
| 264 | + return null; |
|
| 265 | + } |
|
| 244 | 266 | |
| 245 | - if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
| 267 | + if ($code <= 199) { |
|
| 268 | + throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
| 269 | + } |
|
| 246 | 270 | |
| 247 | - if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
| 271 | + if ($code == 403) { |
|
| 272 | + throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
| 273 | + } |
|
| 248 | 274 | |
| 249 | 275 | throw new LiveStreamException(self::ERROR_CODES[$code]); |
| 250 | 276 | } |