@@ -366,38 +366,38 @@ discard block |
||
366 | 366 | { |
367 | 367 | |
368 | 368 | // If no data was returned, no resource was found |
369 | - if($this->getRawData() === null) |
|
369 | + if ($this->getRawData() === null) |
|
370 | 370 | { |
371 | 371 | throw new ResourceNotFoundException('The resource wasn\'t found', 404); |
372 | 372 | } |
373 | 373 | |
374 | - $responseBody = (array_key_exists(0, $this->getRawData())?$this->getRawData()[0]:$this->getRawData()); |
|
374 | + $responseBody = (array_key_exists(0, $this->getRawData()) ? $this->getRawData()[0] : $this->getRawData()); |
|
375 | 375 | |
376 | 376 | // Process the standard error code response. |
377 | 377 | |
378 | - if(array_key_exists('errors', $responseBody) || array_key_exists('error', $responseBody)) |
|
378 | + if (array_key_exists('errors', $responseBody) || array_key_exists('error', $responseBody)) |
|
379 | 379 | { |
380 | 380 | $errors = []; |
381 | 381 | // Get the errors |
382 | - if(array_key_exists('errors', $responseBody)) |
|
382 | + if (array_key_exists('errors', $responseBody)) |
|
383 | 383 | { |
384 | 384 | $errors = $responseBody['errors']; |
385 | - } elseif(array_key_exists('error', $responseBody)) |
|
385 | + } elseif (array_key_exists('error', $responseBody)) |
|
386 | 386 | { |
387 | 387 | $errors = $responseBody['error']; |
388 | 388 | } |
389 | 389 | |
390 | 390 | // Standardize the errors. If the errors aren't in an enclosing array, put them in one so we can iterate through them |
391 | - if(! array_key_exists(0, $errors)) |
|
391 | + if (!array_key_exists(0, $errors)) |
|
392 | 392 | { |
393 | 393 | $errors = [$errors]; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Throw the error |
397 | 397 | // TODO allow all errors to be seen by the user |
398 | - foreach($errors as $error) |
|
398 | + foreach ($errors as $error) |
|
399 | 399 | { |
400 | - if(array_key_exists('error_code', $error) && array_key_exists('error_message', $error)) |
|
400 | + if (array_key_exists('error_code', $error) && array_key_exists('error_message', $error)) |
|
401 | 401 | { |
402 | 402 | $this->throwCustomUnionCloudError($error); |
403 | 403 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | { |
425 | 425 | $errorCode = $error['error_code']; |
426 | 426 | $errorMessage = $error['error_message']; |
427 | - if(($errorDetails = $this->getUnionCloudErrorDetails($errorCode)) !== false) |
|
427 | + if (($errorDetails = $this->getUnionCloudErrorDetails($errorCode)) !== false) |
|
428 | 428 | { |
429 | 429 | throw new $errorDetails['errorClass']($errorDetails['message'], $errorDetails['code'], null, $errorCode, $errorMessage); |
430 | 430 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | ], |
762 | 762 | ]; |
763 | 763 | |
764 | - if(array_key_exists($errorCode, $errors)) |
|
764 | + if (array_key_exists($errorCode, $errors)) |
|
765 | 765 | { |
766 | 766 | $error = $errors[$errorCode]; |
767 | 767 | return [ |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | $parsedResource = $this->parseResource($resource); |
791 | 791 | $resources->addResource($parsedResource); |
792 | 792 | } |
793 | - } catch(\Exception $e) { |
|
793 | + } catch (\Exception $e) { |
|
794 | 794 | // See the above TODO |
795 | 795 | } |
796 | 796 | return $resources; |
@@ -84,9 +84,9 @@ |
||
84 | 84 | public function parseCustomResource($attributeValue, $resourceClass) |
85 | 85 | { |
86 | 86 | $collection = new ResourceCollection(); |
87 | - foreach($attributeValue as $resource) |
|
87 | + foreach ($attributeValue as $resource) |
|
88 | 88 | { |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $collection->addResource(new $resourceClass($resource)); |
91 | 91 | } catch (\Exception $e) |
92 | 92 | { |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function setAllAttributes($attributes) |
99 | 99 | { |
100 | - foreach($attributes as $attributeKey => $value) |
|
100 | + foreach ($attributes as $attributeKey => $value) |
|
101 | 101 | { |
102 | 102 | $value = $this->castAttribute($attributeKey, $value); |
103 | - if($value !== null) // Will occur for customCasts, since we don't want the attribute to exist in this class but in the child resource |
|
103 | + if ($value !== null) // Will occur for customCasts, since we don't want the attribute to exist in this class but in the child resource |
|
104 | 104 | { |
105 | 105 | $this->attributes[$attributeKey] = $value; |
106 | 106 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function __get($attributeKey) |
124 | 124 | { |
125 | - if($this->doesAttributeExist($attributeKey)) { |
|
125 | + if ($this->doesAttributeExist($attributeKey)) { |
|
126 | 126 | $attribute = $this->attributes[$attributeKey]; |
127 | 127 | return $attribute; |
128 | 128 | //return $this->castAttribute($attributeKey, $attribute); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function castAttribute($attributeKey, $attributeValue) |
188 | 188 | { |
189 | - if(($castTo = $this->getAttributeCastSetting($attributeKey)) !== false) |
|
189 | + if (($castTo = $this->getAttributeCastSetting($attributeKey)) !== false) |
|
190 | 190 | { |
191 | 191 | # Cast is one of date, properName etc |
192 | 192 | return $this->castAttributeFromCode($castTo, $attributeValue); |
193 | - } elseif(($castToSettings = $this->getAttributeCustomCastSettings($attributeKey)) !== false) |
|
193 | + } elseif (($castToSettings = $this->getAttributeCustomCastSettings($attributeKey)) !== false) |
|
194 | 194 | { |
195 | 195 | # Cast is custom |
196 | 196 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | // The attribute to be set in the new handler |
202 | 202 | $newHandlerAttribute = $castToSettings['new_handler_attribute']; |
203 | 203 | |
204 | - if(!$this->doesAttributeExist($newAttribute)) |
|
204 | + if (!$this->doesAttributeExist($newAttribute)) |
|
205 | 205 | { |
206 | 206 | $this->$newAttribute = new $handler([]); |
207 | 207 | } |
@@ -254,9 +254,9 @@ discard block |
||
254 | 254 | |
255 | 255 | private function getAttributeCastSetting($attributeKey) |
256 | 256 | { |
257 | - if(property_exists($this, 'casts')) |
|
257 | + if (property_exists($this, 'casts')) |
|
258 | 258 | { |
259 | - if(array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $this->casts)) |
|
259 | + if (array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $this->casts)) |
|
260 | 260 | { |
261 | 261 | return $this->casts[$camelCase]; |
262 | 262 | } |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | */ |
280 | 280 | private function getAttributeCustomCastSettings($attributeKey) |
281 | 281 | { |
282 | - if(property_exists($this, 'customCasts') && is_array($this->customCasts)) |
|
282 | + if (property_exists($this, 'customCasts') && is_array($this->customCasts)) |
|
283 | 283 | { |
284 | - foreach($this->customCasts as $classSettings=>$customCast) |
|
284 | + foreach ($this->customCasts as $classSettings=>$customCast) |
|
285 | 285 | { |
286 | - if(array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $customCast)) |
|
286 | + if (array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $customCast)) |
|
287 | 287 | { |
288 | 288 | $castSettings = explode('|', $classSettings); |
289 | 289 | return [ |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @return bool |
331 | 331 | */ |
332 | - private function doesAttributeExist($attributeKey, $type='camel') |
|
332 | + private function doesAttributeExist($attributeKey, $type = 'camel') |
|
333 | 333 | { |
334 | - if($type === 'camel') |
|
334 | + if ($type === 'camel') |
|
335 | 335 | { |
336 | 336 | $attributeKey = $this->fromCamelToSnake($attributeKey); |
337 | 337 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | { |
340 | 340 | if (array_key_exists($attributeKey, $this->attributes)) { |
341 | 341 | // TODO Check the attribute key isn't blank |
342 | - if($this->attributes[$attributeKey]) |
|
342 | + if ($this->attributes[$attributeKey]) |
|
343 | 343 | { |
344 | 344 | return true; |
345 | 345 | } |