Passed
Push — master ( f42972...200c28 )
by Supun
02:29
created
src/Extractor/JsonExtractor.php 1 patch
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -194,12 +194,13 @@
 block discarded – undo
194 194
             foreach ($data ?? [] as $Column => $Value) {
195 195
                 if (!is_array($Value) && !is_object($Value) && !empty($Column) && !is_numeric($Column)) {
196 196
 
197
-                    if (isset($ForeignKeys[JsonExtractor::snakeCase($table)]) && $ForeignKeys[JsonExtractor::snakeCase($table)]['name'] == JsonExtractor::snakeCase($Column))
198
-                        $Columns[] = ['name' => $Column, 'type' => 'foreign_key', 'ref' => $ForeignKeys[JsonExtractor::snakeCase($table)]['ref']];
199
-                    elseif ($Column == 'id')
200
-                        $Columns[] = ['name' => $Column, 'type' => 'primary_key'];
201
-                    else
202
-                        $Columns[] = ['name' => $Column, 'type' => gettype($this->getActualDataType($Value, ""))];
197
+                    if (isset($ForeignKeys[JsonExtractor::snakeCase($table)]) && $ForeignKeys[JsonExtractor::snakeCase($table)]['name'] == JsonExtractor::snakeCase($Column)) {
198
+                                            $Columns[] = ['name' => $Column, 'type' => 'foreign_key', 'ref' => $ForeignKeys[JsonExtractor::snakeCase($table)]['ref']];
199
+                    } elseif ($Column == 'id') {
200
+                                            $Columns[] = ['name' => $Column, 'type' => 'primary_key'];
201
+                    } else {
202
+                                            $Columns[] = ['name' => $Column, 'type' => gettype($this->getActualDataType($Value, ""))];
203
+                    }
203 204
                 }
204 205
             }
205 206
         } elseif (is_array($data)) {
Please login to merge, or discard this patch.
src/Helpers/Json.php 1 patch
Braces   +19 added lines, -11 removed lines patch added patch discarded remove patch
@@ -81,18 +81,22 @@  discard block
 block discarded – undo
81 81
     private function addID($array, $parent_table = false, $last_increment = false)
82 82
     {
83 83
 
84
-        if (!is_array($array))
85
-            $array = json_decode($array, true);//if this is not the first time decode the text
84
+        if (!is_array($array)) {
85
+                    $array = json_decode($array, true);
86
+        }
87
+        //if this is not the first time decode the text
86 88
 
87 89
         $return_array = $array;//return array
88 90
 
89 91
         foreach ($array ?? [] as $key => $array_item) {
90 92
 
91
-            if (!is_numeric($key) && $parent_table)//single array table, no column
93
+            if (!is_numeric($key) && $parent_table) {
94
+             //single array table, no column
92 95
                 $table_name = $parent_table . '_' . $key;
93
-            elseif ($parent_table)//multiple array items
96
+            } elseif ($parent_table) {
97
+             //multiple array items
94 98
                 $table_name = $parent_table;
95
-            else {//first time loop
99
+            } else {//first time loop
96 100
                 $table_name = $this->main_table_name;
97 101
             }
98 102
 
@@ -129,21 +133,25 @@  discard block
 block discarded – undo
129 133
      */
130 134
     private function addForeign($array, $parent_table = null, $parent_key = false)
131 135
     {
132
-        if (!is_array($array))
133
-            $array = json_decode($array, true);
136
+        if (!is_array($array)) {
137
+                    $array = json_decode($array, true);
138
+        }
134 139
 
135 140
         $return_array = $array;
136 141
         foreach ($array ?? [] as $key => $array_item) {
137 142
 
138 143
 
139 144
 
140
-            if (!is_numeric($key) && $parent_table)//single array table, no column
145
+            if (!is_numeric($key) && $parent_table) {
146
+             //single array table, no column
141 147
                 $table_name = $parent_table . '_' . $key;
142
-            elseif ($parent_table)//multiple array items
148
+            } elseif ($parent_table) {
149
+             //multiple array items
143 150
                 $table_name = $parent_table;
144
-            elseif (!is_numeric($key))  //first time loop
151
+            } elseif (!is_numeric($key)) {
152
+             //first time loop
145 153
                 $table_name = $key;
146
-            else {//first time loop
154
+            } else {//first time loop
147 155
                 $table_name = $this->main_table_name;
148 156
             }
149 157
 
Please login to merge, or discard this patch.