Passed
Push — master ( 7ac1e8...3f7aca )
by Toby
02:34
created
src/Traits/ParsesAttributes.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
 trait ParsesAttributes
29 29
 {
30 30
 
31
-     /**
32
-     * Convert camelCase to snake_case
33
-     *
34
-     * @param string $key
35
-     *
36
-     * @return string
37
-     */
31
+        /**
32
+         * Convert camelCase to snake_case
33
+         *
34
+         * @param string $key
35
+         *
36
+         * @return string
37
+         */
38 38
     public function fromCamelToSnake($key)
39 39
     {
40 40
         preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $key, $matches);
Please login to merge, or discard this patch.
src/Traits/CastsAttributes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@
 block discarded – undo
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
             {
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,17 +52,19 @@
 block discarded – undo
52 52
             $newWords = array();
53 53
             foreach ($words as $word)
54 54
             {
55
-                if (in_array(strtoupper($word), $uppercase_exceptions))
56
-                    $word = strtoupper($word);
57
-                else
58
-                    if (!in_array($word, $lowercase_exceptions))
59
-                        $word = ucfirst($word);
55
+                if (in_array(strtoupper($word), $uppercase_exceptions)) {
56
+                                    $word = strtoupper($word);
57
+                } else
58
+                    if (!in_array($word, $lowercase_exceptions)) {
59
+                                            $word = ucfirst($word);
60
+                    }
60 61
 
61 62
                 $newWords[] = $word;
62 63
             }
63 64
 
64
-            if (in_array(strtolower($delimiter), $lowercase_exceptions))
65
-                $delimiter = strtolower($delimiter);
65
+            if (in_array(strtolower($delimiter), $lowercase_exceptions)) {
66
+                            $delimiter = strtolower($delimiter);
67
+            }
66 68
 
67 69
             $attributeValue = join($delimiter, $newWords);
68 70
         }
Please login to merge, or discard this patch.
src/Resource/BaseResource.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,10 +100,12 @@
 block discarded – undo
100 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) {
104
+                // Will occur for customCasts, since we don't want the attribute to exist in this class but in the child resource
104 105
             {
105 106
                 $this->attributes[$attributeKey] = $value;
106 107
             }
108
+            }
107 109
         }
108 110
     }
109 111
 
Please login to merge, or discard this patch.
src/Request/BaseRequest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -397,13 +397,13 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -373,8 +373,7 @@  discard block
 block discarded – undo
373 373
      */
374 374
     protected function setContentType($contentType)
375 375
     {
376
-        if ($contentType === 'json') { $contentType = 'application/json'; }
377
-        elseif ($contentType === 'form') { $contentType = 'application/x-www-form-urlencoded'; }
376
+        if ($contentType === 'json') { $contentType = 'application/json'; } elseif ($contentType === 'form') { $contentType = 'application/x-www-form-urlencoded'; }
378 377
         $this->contentType = $contentType;
379 378
     }
380 379
 
@@ -551,8 +550,7 @@  discard block
 block discarded – undo
551 550
     {
552 551
         if (!$this->contentType)
553 552
         {
554
-            if ($this->getMethod() === 'POST') { return 'application/x-www-form-urlencoded'; }
555
-            else { return 'application/json'; }
553
+            if ($this->getMethod() === 'POST') { return 'application/x-www-form-urlencoded'; } else { return 'application/json'; }
556 554
         }
557 555
         return $this->contentType;
558 556
     }
Please login to merge, or discard this patch.
src/Request/UserGroupMembershipRequest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.