Passed
Push — master ( 7aec2e...e63691 )
by Smoren
13:05
created
src/ArrayMapper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
     ): array {
27 27
         $result = [];
28 28
 
29
-        foreach($input as $item) {
30
-            if($ignoreNulls && !static::isFieldsNotNull($item, $mapFields)) {
29
+        foreach ($input as $item) {
30
+            if ($ignoreNulls && !static::isFieldsNotNull($item, $mapFields)) {
31 31
                 continue;
32 32
             }
33 33
             $resultPointer = &$result;
34
-            foreach($mapFields as $field) {
34
+            foreach ($mapFields as $field) {
35 35
                 $fieldValue = static::getFieldValue($item, $field);
36
-                if(!is_scalar($fieldValue)) {
36
+                if (!is_scalar($fieldValue)) {
37 37
                     $field = strval($field);
38 38
                     throw new ArrayMapperException(
39 39
                         "field value of '{$field}' is not scalar",
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                     );
48 48
                 }
49 49
                 /** @var array<string|int|bool|null, mixed> $resultPointer */
50
-                if(!isset($resultPointer[$fieldValue])) {
50
+                if (!isset($resultPointer[$fieldValue])) {
51 51
                     $resultPointer[$fieldValue] = [];
52 52
                 }
53 53
                 $resultPointer = &$resultPointer[$fieldValue];
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
             $value = is_callable($valueGetter) ? $valueGetter($item) : $item;
57 57
 
58
-            if($multiple) {
58
+            if ($multiple) {
59 59
                 /** @var array<mixed> $resultPointer */
60 60
                 $resultPointer[] = $value;
61 61
             } else {
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected static function isFieldsNotNull($source, array $fieldNames): bool
76 76
     {
77
-        foreach($fieldNames as $fieldName) {
77
+        foreach ($fieldNames as $fieldName) {
78 78
             try {
79
-                if(static::getFieldValue($source, $fieldName) === null) {
79
+                if (static::getFieldValue($source, $fieldName) === null) {
80 80
                     return false;
81 81
                 }
82
-            } catch(ArrayMapperException $e) {
82
+            } catch (ArrayMapperException $e) {
83 83
                 return false;
84 84
             }
85 85
         }
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
      */
97 97
     protected static function getFieldValue($source, $fieldName)
98 98
     {
99
-        if(is_callable($fieldName)) {
99
+        if (is_callable($fieldName)) {
100 100
             return $fieldName($source);
101 101
         }
102 102
 
103
-        if(
104
-            is_array($source) && !array_key_exists((string)$fieldName, $source)
105
-            || is_object($source) && !isset($source->{$fieldName}) && !property_exists($source, (string)$fieldName)
103
+        if (
104
+            is_array($source) && !array_key_exists((string) $fieldName, $source)
105
+            || is_object($source) && !isset($source->{$fieldName}) && !property_exists($source, (string) $fieldName)
106 106
         ) {
107 107
             throw new ArrayMapperException(
108 108
                 "field '{$fieldName}' not exist",
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
             );
116 116
         }
117 117
 
118
-        if(is_array($source)) {
118
+        if (is_array($source)) {
119 119
             return $source[$fieldName];
120
-        } elseif(is_object($source)) {
120
+        } elseif (is_object($source)) {
121 121
             return $source->{$fieldName};
122 122
         } else {
123 123
             throw new ArrayMapperException(
Please login to merge, or discard this patch.