@@ -129,16 +129,22 @@ discard block |
||
129 | 129 | $response = $this->getClient()->curl_api($this->getURL(), 'GET', $data); |
130 | 130 | $data = ($response->isValid() && $response->isJSON()) ? $response->getJSON() : []; |
131 | 131 | |
132 | - if (empty($data)) throw new ApiException($response->getError()); |
|
132 | + if (empty($data)) { |
|
133 | + throw new ApiException($response->getError()); |
|
134 | + } |
|
133 | 135 | |
134 | 136 | $this->_max_items = (int) $data['available_items']; |
135 | 137 | |
136 | - if (empty($data['items'])) return $this->_items[$page] = []; |
|
138 | + if (empty($data['items'])) { |
|
139 | + return $this->_items[$page] = []; |
|
140 | + } |
|
137 | 141 | |
138 | 142 | |
139 | 143 | foreach ($data['items'] as $item) { |
140 | 144 | $obj = ObjectFactory::make($this->getClient(), $item); |
141 | - if (!$obj) continue; |
|
145 | + if (!$obj) { |
|
146 | + continue; |
|
147 | + } |
|
142 | 148 | |
143 | 149 | $this->_items[$page][] = $obj; |
144 | 150 | } |
@@ -153,7 +159,9 @@ discard block |
||
153 | 159 | */ |
154 | 160 | public function offsetGet($offset): ?ObjectResource |
155 | 161 | { |
156 | - foreach ($this as $i => $obj) if ($i === $offset) return $obj; |
|
162 | + foreach ($this as $i => $obj) { |
|
163 | + if ($i === $offset) return $obj; |
|
164 | + } |
|
157 | 165 | return null; |
158 | 166 | } |
159 | 167 | |
@@ -184,7 +192,9 @@ discard block |
||
184 | 192 | */ |
185 | 193 | public function offsetExists($offset): bool |
186 | 194 | { |
187 | - foreach ($this as $i => $obj) if ($offset === $i) return true; |
|
195 | + foreach ($this as $i => $obj) { |
|
196 | + if ($offset === $i) return true; |
|
197 | + } |
|
188 | 198 | return false; |
189 | 199 | } |
190 | 200 | |
@@ -240,6 +250,8 @@ discard block |
||
240 | 250 | */ |
241 | 251 | public function first(): ?Model |
242 | 252 | { |
243 | - foreach ($this as $obj) return $obj; |
|
253 | + foreach ($this as $obj) { |
|
254 | + return $obj; |
|
255 | + } |
|
244 | 256 | } |
245 | 257 | } |
@@ -109,7 +109,9 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getAPIChallenge(bool $check_session = true): string |
111 | 111 | { |
112 | - if ($this->_api_challenge) return $this->_api_challenge; |
|
112 | + if ($this->_api_challenge) { |
|
113 | + return $this->_api_challenge; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | if ($check_session && session_status() === PHP_SESSION_ACTIVE) { |
115 | 117 | $this->setAPIChallenge($_SESSION[self::API_CHALLENGE_PARAM] ?? ''); |
@@ -169,7 +171,9 @@ discard block |
||
169 | 171 | */ |
170 | 172 | public function getAccessToken(bool $check_session = true): string |
171 | 173 | { |
172 | - if ($this->_access_token) return $this->_access_token; |
|
174 | + if ($this->_access_token) { |
|
175 | + return $this->_access_token; |
|
176 | + } |
|
173 | 177 | |
174 | 178 | if ($check_session && session_status() === PHP_SESSION_ACTIVE) { |
175 | 179 | $this->setAccessToken($_SESSION[self::ACCESS_TOKEN_PARAM] ?? ''); |