@@ -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 | |
| 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 $this->castAttribute($attributeKey, $attribute); |
| 128 | 128 | } |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | private function castAttribute($attributeKey, $attributeValue) |
| 187 | 187 | {
|
| 188 | - if(($castTo = $this->getAttributeCastSetting($attributeKey)) !== false) |
|
| 188 | + if (($castTo = $this->getAttributeCastSetting($attributeKey)) !== false) |
|
| 189 | 189 | {
|
| 190 | 190 | return $this->castAttributeFromCode($castTo, $attributeValue); |
| 191 | - } elseif(($castToSettings = $this->getAttributeCustomCastSettings($attributeKey)) !== false) |
|
| 191 | + } elseif (($castToSettings = $this->getAttributeCustomCastSettings($attributeKey)) !== false) |
|
| 192 | 192 | {
|
| 193 | 193 | // The attribute under which the new resource is accessible |
| 194 | 194 | $newAttribute = $castToSettings['new_attribute']; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | // The attribute to be set in the new handler |
| 200 | 200 | $newHandlerAttribute = $castToSettings['new_handler_attribute']; |
| 201 | 201 | |
| 202 | - if(!$this->doesAttributeExist($newAttribute)) |
|
| 202 | + if (!$this->doesAttributeExist($newAttribute)) |
|
| 203 | 203 | {
|
| 204 | 204 | $this->$newAttribute = new $handler([]); |
| 205 | 205 | } |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | private function getAttributeCastSetting($attributeKey) |
| 254 | 254 | {
|
| 255 | - if(property_exists($this, 'casts')) |
|
| 255 | + if (property_exists($this, 'casts')) |
|
| 256 | 256 | {
|
| 257 | - if(array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $this->casts)) |
|
| 257 | + if (array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $this->casts)) |
|
| 258 | 258 | {
|
| 259 | 259 | return $this->casts[$camelCase]; |
| 260 | 260 | } |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | private function getAttributeCustomCastSettings($attributeKey) |
| 279 | 279 | {
|
| 280 | - if(property_exists($this, 'customCasts') && is_array($this->customCasts)) |
|
| 280 | + if (property_exists($this, 'customCasts') && is_array($this->customCasts)) |
|
| 281 | 281 | {
|
| 282 | - foreach($this->customCasts as $classSettings=>$customCast) |
|
| 282 | + foreach ($this->customCasts as $classSettings=>$customCast) |
|
| 283 | 283 | {
|
| 284 | - if(array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $customCast)) |
|
| 284 | + if (array_key_exists($camelCase = $this->fromSnakeToCamel($attributeKey), $customCast)) |
|
| 285 | 285 | {
|
| 286 | 286 | $castSettings = explode('|', $classSettings);
|
| 287 | 287 | return [ |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @return bool |
| 329 | 329 | */ |
| 330 | - private function doesAttributeExist($attributeKey, $type='camel') |
|
| 330 | + private function doesAttributeExist($attributeKey, $type = 'camel') |
|
| 331 | 331 | {
|
| 332 | - if($type === 'camel') |
|
| 332 | + if ($type === 'camel') |
|
| 333 | 333 | {
|
| 334 | 334 | $attributeKey = $this->fromCamelToSnake($attributeKey); |
| 335 | 335 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | {
|
| 338 | 338 | if (array_key_exists($attributeKey, $this->attributes)) {
|
| 339 | 339 | // TODO Check the attribute key isn't blank |
| 340 | - if($this->attributes[$attributeKey]) |
|
| 340 | + if ($this->attributes[$attributeKey]) |
|
| 341 | 341 | {
|
| 342 | 342 | return true; |
| 343 | 343 | } |
@@ -397,13 +397,13 @@ |
||
| 397 | 397 | * @param string $method |
| 398 | 398 | * @param array|null $body If you don't include it in a data array, we will |
| 399 | 399 | */ |
| 400 | - protected function setAPIParameters($endpoint,$method,$body=null) |
|
| 400 | + protected function setAPIParameters($endpoint, $method, $body = null) |
|
| 401 | 401 | {
|
| 402 | 402 | $this->setEndpoint($endpoint); |
| 403 | 403 | $this->setMethod($method); |
| 404 | - if($body !== null) |
|
| 404 | + if ($body !== null) |
|
| 405 | 405 | {
|
| 406 | - $this->setBody((array_key_exists('data', $body)?$body:array('data'=>$body)));
|
|
| 406 | + $this->setBody((array_key_exists('data', $body) ? $body : array('data'=>$body)));
|
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
@@ -78,8 +78,8 @@ |
||
| 78 | 78 | 'GET' |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - if($updatedAfter !== null) { $this->addQueryParameter('updated_at_after', $updatedAfter->format('d-m-y H:i:s')); }
|
|
| 82 | - if($updatedBefore !== null) { $this->addQueryParameter('updated_at_before', $updatedBefore->format('d-m-y H:i:s')); }
|
|
| 81 | + if ($updatedAfter !== null) { $this->addQueryParameter('updated_at_after', $updatedAfter->format('d-m-y H:i:s')); }
|
|
| 82 | + if ($updatedBefore !== null) { $this->addQueryParameter('updated_at_before', $updatedBefore->format('d-m-y H:i:s')); }
|
|
| 83 | 83 | |
| 84 | 84 | $this->enableMode(); |
| 85 | 85 | $this->enablePagination(); |