| @@ -73,7 +73,9 @@ discard block | ||
| 73 | 73 | public function getAccount(int $accountId): ?Account | 
| 74 | 74 |      { | 
| 75 | 75 |          $response = $this->request("accounts/$accountId"); | 
| 76 | - if ($response === null) return null; | |
| 76 | +        if ($response === null) { | |
| 77 | + return null; | |
| 78 | + } | |
| 77 | 79 | |
| 78 | 80 | return Account::fromObject(json_decode($response)); | 
| 79 | 81 | } | 
| @@ -87,7 +89,9 @@ discard block | ||
| 87 | 89 | */ | 
| 88 | 90 | public function createEvent(int $accountId, Event &$event): bool | 
| 89 | 91 |      { | 
| 90 | -        if (!$event->fullName) throw new InValidResourceException('Event', 'fullName'); | |
| 92 | +        if (!$event->fullName) { | |
| 93 | +            throw new InValidResourceException('Event', 'fullName'); | |
| 94 | + } | |
| 91 | 95 | |
| 92 | 96 |          if ($event->isPasswordProtected && !$event->password) { | 
| 93 | 97 |              throw new InValidResourceException('Event', 'password (password must be present for a password protected event)'); | 
| @@ -95,7 +99,9 @@ discard block | ||
| 95 | 99 | |
| 96 | 100 |          $response = $this->request("accounts/$accountId/events", 'post', $event); | 
| 97 | 101 | |
| 98 | - if ($response === null) return false; | |
| 102 | +        if ($response === null) { | |
| 103 | + return false; | |
| 104 | + } | |
| 99 | 105 | |
| 100 | 106 | $event = Event::fromObject(json_decode($response)); | 
| 101 | 107 | |
| @@ -124,7 +130,9 @@ discard block | ||
| 124 | 130 | 'saveVideo' => $saveVideo | 
| 125 | 131 | ]); | 
| 126 | 132 | |
| 127 | - if ($response === null) return null; | |
| 133 | +        if ($response === null) { | |
| 134 | + return null; | |
| 135 | + } | |
| 128 | 136 | |
| 129 | 137 | return RTMPKey::fromObject(json_decode($response)); | 
| 130 | 138 | } | 
| @@ -140,7 +148,9 @@ discard block | ||
| 140 | 148 |      { | 
| 141 | 149 |          $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put'); | 
| 142 | 150 | |
| 143 | - if ($response === null) return null; | |
| 151 | +        if ($response === null) { | |
| 152 | + return null; | |
| 153 | + } | |
| 144 | 154 | |
| 145 | 155 | return RTMPKey::fromObject(json_decode($response)); | 
| 146 | 156 | } | 
| @@ -169,8 +179,12 @@ discard block | ||
| 169 | 179 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | 
| 170 | 180 | |
| 171 | 181 |          if ($verb != 'get') { | 
| 172 | - if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true); | |
| 173 | - if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); | |
| 182 | +            if ($verb == 'post') { | |
| 183 | + curl_setopt($ch, CURLOPT_POST, true); | |
| 184 | + } | |
| 185 | +            if ($verb == 'put') { | |
| 186 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); | |
| 187 | + } | |
| 174 | 188 |              if ($body) { | 
| 175 | 189 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ | 
| 176 | 190 | 'Content-Type: ' . $body->getContentType() | 
| @@ -184,13 +198,21 @@ discard block | ||
| 184 | 198 | |
| 185 | 199 | curl_close($ch); | 
| 186 | 200 | |
| 187 | - if ($code == 200 || $code == 201) return $response; | |
| 201 | +        if ($code == 200 || $code == 201) { | |
| 202 | + return $response; | |
| 203 | + } | |
| 188 | 204 | |
| 189 | - if ($code == 404) return null; | |
| 205 | +        if ($code == 404) { | |
| 206 | + return null; | |
| 207 | + } | |
| 190 | 208 | |
| 191 | -        if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred."); | |
| 209 | +        if ($code <= 199) { | |
| 210 | +            throw new Exception("A CURL erorr with code '$code', has occurred."); | |
| 211 | + } | |
| 192 | 212 | |
| 193 | - if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); | |
| 213 | +        if ($code == 403) { | |
| 214 | + throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); | |
| 215 | + } | |
| 194 | 216 | |
| 195 | 217 | throw new LiveStreamException(self::ERROR_CODES[$code]); | 
| 196 | 218 | } | 
| @@ -36,7 +36,9 @@ discard block | ||
| 36 | 36 | */ | 
| 37 | 37 | public static function fromObject(?object $object): ?Event | 
| 38 | 38 |      { | 
| 39 | - if ($object == null) return null; | |
| 39 | +        if ($object == null) { | |
| 40 | + return null; | |
| 41 | + } | |
| 40 | 42 | |
| 41 | 43 | $instance = new static(false); | 
| 42 | 44 | $instance->data = $object; | 
| @@ -218,7 +220,9 @@ discard block | ||
| 218 | 220 | */ | 
| 219 | 221 | public function addTag(string $tag): Event | 
| 220 | 222 |      { | 
| 221 | - if (!isset($this->data->tags)) $this->data->tags = ''; | |
| 223 | +        if (!isset($this->data->tags)) { | |
| 224 | + $this->data->tags = ''; | |
| 225 | + } | |
| 222 | 226 | |
| 223 | 227 | $this->data->tags .= rtrim($tag, ',') . ','; | 
| 224 | 228 | |
| @@ -244,37 +248,67 @@ discard block | ||
| 244 | 248 |      { | 
| 245 | 249 | $body = ['fullName' => $this->data->fullName]; | 
| 246 | 250 | |
| 247 | - if ($this->data->shortName ?? null) | |
| 248 | - $body['shortName'] = $this->data->shortName; | |
| 251 | +        if ($this->data->shortName ?? null) { | |
| 252 | + $body['shortName'] = $this->data->shortName; | |
| 253 | + } | |
| 249 | 254 | |
| 250 | - if ($this->data->startTime ?? null) | |
| 251 | - $body['startTime'] = $this->data->startTime; | |
| 255 | +        if ($this->data->startTime ?? null) { | |
| 256 | + $body['startTime'] = $this->data->startTime; | |
| 257 | + } | |
| 252 | 258 | |
| 253 | - if ($this->data->endTime ?? null) | |
| 254 | - $body['endTime'] = $this->data->endTime; | |
| 259 | +        if ($this->data->endTime ?? null) { | |
| 260 | + $body['endTime'] = $this->data->endTime; | |
| 261 | + } | |
| 255 | 262 | |
| 256 | - if ($this->data->draft ?? null) | |
| 257 | - $body['draft'] = $this->data->draft; | |
| 263 | +        if ($this->data->draft ?? null) { | |
| 264 | + $body['draft'] = $this->data->draft; | |
| 265 | + } | |
| 258 | 266 | |
| 259 | - if ($this->data->description ?? null) | |
| 260 | - $body['description'] = $this->data->description; | |
| 267 | +        if ($this->data->description ?? null) { | |
| 268 | + $body['description'] = $this->data->description; | |
| 269 | + } | |
| 261 | 270 | |
| 262 | - if ($this->data->tags ?? null) | |
| 263 | - $body['tags'] = rtrim($this->data->tags, ','); | |
| 271 | +        if ($this->data->tags ?? null) { | |
| 272 | + $body['tags'] = rtrim($this->data->tags, ','); | |
| 273 | + } | |
| 264 | 274 | |
| 265 | 275 | /* TODO: Getters & Setters */ | 
| 266 | - if ($this->data->isPublic ?? null) $body['isPublic'] = $this->data->isPublic; | |
| 267 | - if ($this->data->isSearchable ?? null) $body['isSearchable'] = $this->data->isSearchable; | |
| 268 | - if ($this->data->viewerCountVisible ?? null) $body['viewerCountVisible'] = $this->data->viewerCountVisible; | |
| 269 | - if ($this->data->postCommentsEnabled ?? null) $body['postCommentsEnabled'] = $this->data->postCommentsEnabled; | |
| 270 | - if ($this->data->liveChatEnabled ?? null) $body['liveChatEnabled'] = $this->data->liveChatEnabled; | |
| 271 | - if ($this->data->isEmbeddable ?? null) $body['isEmbeddable'] = $this->data->isEmbeddable; | |
| 272 | - if ($this->data->isPasswordProtected ?? null) $body['isPasswordProtected'] = $this->data->isPasswordProtected; | |
| 273 | - if ($this->data->password ?? null) $body['password'] = $this->data->password; | |
| 274 | - if ($this->data->isWhiteLabeled ?? null) $body['isWhiteLabeled'] = $this->data->isWhiteLabeled; | |
| 275 | - if ($this->data->embedRestriction ?? null && in_array($this->data->embedRestriction, ['off', 'whitelist', 'blacklist'])) $body['embedRestriction'] = $this->data->embedRestriction; | |
| 276 | - if ($this->data->embedRestrictionWhitelist ?? null) $body['embedRestrictionWhitelist'] = $this->data->embedRestrictionWhitelist; | |
| 277 | - if ($this->data->embedRestrictionBlacklist ?? null) $body['embedRestrictionBlacklist'] = $this->data->embedRestrictionBlacklist; | |
| 276 | +        if ($this->data->isPublic ?? null) { | |
| 277 | + $body['isPublic'] = $this->data->isPublic; | |
| 278 | + } | |
| 279 | +        if ($this->data->isSearchable ?? null) { | |
| 280 | + $body['isSearchable'] = $this->data->isSearchable; | |
| 281 | + } | |
| 282 | +        if ($this->data->viewerCountVisible ?? null) { | |
| 283 | + $body['viewerCountVisible'] = $this->data->viewerCountVisible; | |
| 284 | + } | |
| 285 | +        if ($this->data->postCommentsEnabled ?? null) { | |
| 286 | + $body['postCommentsEnabled'] = $this->data->postCommentsEnabled; | |
| 287 | + } | |
| 288 | +        if ($this->data->liveChatEnabled ?? null) { | |
| 289 | + $body['liveChatEnabled'] = $this->data->liveChatEnabled; | |
| 290 | + } | |
| 291 | +        if ($this->data->isEmbeddable ?? null) { | |
| 292 | + $body['isEmbeddable'] = $this->data->isEmbeddable; | |
| 293 | + } | |
| 294 | +        if ($this->data->isPasswordProtected ?? null) { | |
| 295 | + $body['isPasswordProtected'] = $this->data->isPasswordProtected; | |
| 296 | + } | |
| 297 | +        if ($this->data->password ?? null) { | |
| 298 | + $body['password'] = $this->data->password; | |
| 299 | + } | |
| 300 | +        if ($this->data->isWhiteLabeled ?? null) { | |
| 301 | + $body['isWhiteLabeled'] = $this->data->isWhiteLabeled; | |
| 302 | + } | |
| 303 | +        if ($this->data->embedRestriction ?? null && in_array($this->data->embedRestriction, ['off', 'whitelist', 'blacklist'])) { | |
| 304 | + $body['embedRestriction'] = $this->data->embedRestriction; | |
| 305 | + } | |
| 306 | +        if ($this->data->embedRestrictionWhitelist ?? null) { | |
| 307 | + $body['embedRestrictionWhitelist'] = $this->data->embedRestrictionWhitelist; | |
| 308 | + } | |
| 309 | +        if ($this->data->embedRestrictionBlacklist ?? null) { | |
| 310 | + $body['embedRestrictionBlacklist'] = $this->data->embedRestrictionBlacklist; | |
| 311 | + } | |
| 278 | 312 | |
| 279 | 313 | return json_encode($body); | 
| 280 | 314 | } |