@@ -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 | /** |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | public function __construct(string $fullName, bool $init = true) |
18 | 18 | { |
19 | 19 | parent::__construct($init); |
20 | - if ($init) |
|
21 | - $this->data->fullName = $fullName; |
|
20 | + if ($init) { |
|
21 | + $this->data->fullName = $fullName; |
|
22 | + } |
|
22 | 23 | } |
23 | 24 | |
24 | 25 | /** |
@@ -76,7 +77,9 @@ discard block |
||
76 | 77 | */ |
77 | 78 | public function addTag(string $tag): Event |
78 | 79 | { |
79 | - if (!isset($this->data->tags)) $this->data->tags = ''; |
|
80 | + if (!isset($this->data->tags)) { |
|
81 | + $this->data->tags = ''; |
|
82 | + } |
|
80 | 83 | |
81 | 84 | $this->data->tags .= rtrim($tag, ',') . ','; |
82 | 85 | |
@@ -155,8 +158,9 @@ discard block |
||
155 | 158 | private function set_fields(array &$array, array $map): void |
156 | 159 | { |
157 | 160 | foreach ($map as $key => $value) { |
158 | - if ($value) |
|
159 | - $array[$key] = $value; |
|
161 | + if ($value) { |
|
162 | + $array[$key] = $value; |
|
163 | + } |
|
160 | 164 | } |
161 | 165 | } |
162 | 166 |
@@ -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; |
@@ -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 | } |
@@ -159,7 +169,9 @@ discard block |
||
159 | 169 | ): ?string { |
160 | 170 | $ch = curl_init(); |
161 | 171 | |
162 | - if (!$ch) throw new Exception("Could not initialize CURL."); |
|
172 | + if (!$ch) { |
|
173 | + throw new Exception("Could not initialize CURL."); |
|
174 | + } |
|
163 | 175 | |
164 | 176 | curl_setopt( |
165 | 177 | $ch, |
@@ -171,8 +183,12 @@ discard block |
||
171 | 183 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
172 | 184 | |
173 | 185 | if ($verb != 'get') { |
174 | - if ($verb == 'post') curl_setopt($ch, CURLOPT_POST, true); |
|
175 | - if ($verb == 'put') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
186 | + if ($verb == 'post') { |
|
187 | + curl_setopt($ch, CURLOPT_POST, true); |
|
188 | + } |
|
189 | + if ($verb == 'put') { |
|
190 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); |
|
191 | + } |
|
176 | 192 | if ($body) { |
177 | 193 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
178 | 194 | 'Content-Type: ' . $body->getContentType() |
@@ -186,13 +202,21 @@ discard block |
||
186 | 202 | |
187 | 203 | curl_close($ch); |
188 | 204 | |
189 | - if ($code == 200 || $code == 201) return $response; |
|
205 | + if ($code == 200 || $code == 201) { |
|
206 | + return $response; |
|
207 | + } |
|
190 | 208 | |
191 | - if ($code == 404) return null; |
|
209 | + if ($code == 404) { |
|
210 | + return null; |
|
211 | + } |
|
192 | 212 | |
193 | - if ($code <= 199) throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
213 | + if ($code <= 199) { |
|
214 | + throw new Exception("A CURL erorr with code '$code', has occurred."); |
|
215 | + } |
|
194 | 216 | |
195 | - if ($code == 403) throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
217 | + if ($code == 403) { |
|
218 | + throw new LiveStreamException(self::ERROR_CODES[$code] . ' ' . json_decode($response)->message); |
|
219 | + } |
|
196 | 220 | |
197 | 221 | throw new LiveStreamException(self::ERROR_CODES[$code]); |
198 | 222 | } |