@@ -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,11 +89,15 @@ 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 | $response = $this->request("acconts/$accountId/events", 'post', $event); |
93 | 97 | |
94 | - if ($response === null) return false; |
|
98 | + if ($response === null) { |
|
99 | + return false; |
|
100 | + } |
|
95 | 101 | |
96 | 102 | $event = Event::fromObject(json_decode($response)); |
97 | 103 | |
@@ -110,7 +116,9 @@ discard block |
||
110 | 116 | { |
111 | 117 | $response = $this->request("accounts/$accountId/events/$eventId/rtmp"); |
112 | 118 | |
113 | - if ($response === null) return null; |
|
119 | + if ($response === null) { |
|
120 | + return null; |
|
121 | + } |
|
114 | 122 | |
115 | 123 | return RTMPKey::fromObject(json_decode($response)); |
116 | 124 | } |
@@ -126,7 +134,9 @@ discard block |
||
126 | 134 | { |
127 | 135 | $response = $this->request("accounts/$accountId/events/$eventId/rtmp", 'put'); |
128 | 136 | |
129 | - if ($response === null) return null; |
|
137 | + if ($response === null) { |
|
138 | + return null; |
|
139 | + } |
|
130 | 140 | |
131 | 141 | return RTMPKey::fromObject(json_decode($response)); |
132 | 142 | } |
@@ -145,8 +155,12 @@ discard block |
||
145 | 155 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
146 | 156 | |
147 | 157 | if ($verb != 'get') { |
148 | - if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true); |
|
149 | - if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
158 | + if ($verb == 'post') { |
|
159 | + curl_setopt($ch, CURLOPT_POST, true); |
|
160 | + } |
|
161 | + if ($verb == 'put') { |
|
162 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
163 | + } |
|
150 | 164 | if ($body) { |
151 | 165 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
152 | 166 | 'Content-Type: ' . $body->getContentType() |
@@ -159,13 +173,21 @@ discard block |
||
159 | 173 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
160 | 174 | curl_close($ch); |
161 | 175 | |
162 | - if ($code == 200 || $code == 201) return $response; |
|
176 | + if ($code == 200 || $code == 201) { |
|
177 | + return $response; |
|
178 | + } |
|
163 | 179 | |
164 | - if ($code == 404) return null; |
|
180 | + if ($code == 404) { |
|
181 | + return null; |
|
182 | + } |
|
165 | 183 | |
166 | - if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
184 | + if ($code <= 199) { |
|
185 | + throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
186 | + } |
|
167 | 187 | |
168 | - if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
188 | + if ($code == 403) { |
|
189 | + throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
190 | + } |
|
169 | 191 | |
170 | 192 | throw new LiveStreamException(self::ERROR_CODES[$code]); |
171 | 193 | } |
@@ -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,12 +248,24 @@ discard block |
||
244 | 248 | { |
245 | 249 | $body = ['fullName' => $this->data->fullName]; |
246 | 250 | |
247 | - if ($this->data->shortName ?? null) $body['shortName'] = $this->data->shortName; |
|
248 | - if ($this->data->startTime ?? null) $body['startTime'] = $this->data->startTime; |
|
249 | - if ($this->data->endTime ?? null) $body['endTime'] = $this->data->endTime; |
|
250 | - if ($this->data->draft ?? null) $body['draft'] = $this->data->draft; |
|
251 | - if ($this->data->description ?? null) $body['description'] = $this->data->description; |
|
252 | - if ($this->data->tags ?? null) $body['tags'] = rtrim($this->data->tags, ','); |
|
251 | + if ($this->data->shortName ?? null) { |
|
252 | + $body['shortName'] = $this->data->shortName; |
|
253 | + } |
|
254 | + if ($this->data->startTime ?? null) { |
|
255 | + $body['startTime'] = $this->data->startTime; |
|
256 | + } |
|
257 | + if ($this->data->endTime ?? null) { |
|
258 | + $body['endTime'] = $this->data->endTime; |
|
259 | + } |
|
260 | + if ($this->data->draft ?? null) { |
|
261 | + $body['draft'] = $this->data->draft; |
|
262 | + } |
|
263 | + if ($this->data->description ?? null) { |
|
264 | + $body['description'] = $this->data->description; |
|
265 | + } |
|
266 | + if ($this->data->tags ?? null) { |
|
267 | + $body['tags'] = rtrim($this->data->tags, ','); |
|
268 | + } |
|
253 | 269 | |
254 | 270 | return json_encode($body); |
255 | 271 | } |