Completed
Push — master ( 200c28...f6ac24 )
by Supun
03:34 queued 01:19
created
src/Client.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
         //create tables
119 119
         foreach ($JsonExtractor->getTablesArray() as $TableName => $TableColumn) {
120 120
             $this->capsule::schema()->dropIfExists($TableName);
121
-            $this->capsule::schema()->create($TableName, function ($table) use ($TableColumn) {
121
+            $this->capsule::schema()->create($TableName, function($table) use ($TableColumn) {
122 122
                 foreach ($TableColumn as $column_item) {
123 123
                     switch ($column_item['type']) {
124 124
                         case 'int':
Please login to merge, or discard this patch.
src/Extractor/JsonExtractor.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 
75 75
             if (is_array($value) && is_object($value[0])) {//check whether it's a array and it's firs element is a object
76 76
 
77
-                $table_data = $this->getTable($prefix . $table_name, $value); //get table sql
77
+                $table_data = $this->getTable($prefix.$table_name, $value); //get table sql
78 78
                 $this->table[$table_data['name']] = $table_data['column'];
79 79
 
80
-                $this->toMysqlTables($this->getHighestColumnArray($value), $prefix . $table_name . "_", $prefix . $table_name); //get it inside tables
80
+                $this->toMysqlTables($this->getHighestColumnArray($value), $prefix.$table_name."_", $prefix.$table_name); //get it inside tables
81 81
             } elseif (is_array($value) || is_object($value)) {//if it's a array and  firs element is not a object
82 82
 
83
-                $table_data = $this->getTable($prefix . $table_name, $value);
83
+                $table_data = $this->getTable($prefix.$table_name, $value);
84 84
                 $this->table[$table_data['name']] = $table_data['column'];
85 85
             }
86 86
         }
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
         }
100 100
         foreach ($data as $table_name => $value) {
101 101
             if ($this->snake_case_table) {
102
-                $table_name = $this->snakeCase($prefix . $table_name);
102
+                $table_name = $this->snakeCase($prefix.$table_name);
103 103
             }
104 104
             if (is_array($value) && !empty($value) && is_object($value[0])) {//if it's a array and  firs element is not a object
105
-                $this->toMysqlData($value, $table_name . '_');
105
+                $this->toMysqlData($value, $table_name.'_');
106 106
             } elseif (is_object($value) || is_array($value)) {
107
-                $this->toMysqlData($value, $table_name . '_');
107
+                $this->toMysqlData($value, $table_name.'_');
108 108
                 $this->getTableData($table_name, $value);
109 109
             }
110 110
         }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         if ($this->snake_case_column) {
162 162
             return [
163 163
                 'name' => $table,
164
-                'column' => array_map(function ($item) {
164
+                'column' => array_map(function($item) {
165 165
                     return [
166 166
                         'name' => $this->snakeCase($item['name']),
167 167
                         'type' => $item['type'],
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
                 } elseif (is_numeric($item)) {
340 340
                     $value[] = $item;
341 341
                 } else {
342
-                    $value[] = '"' . addcslashes($item, "W") . '"';
342
+                    $value[] = '"'.addcslashes($item, "W").'"';
343 343
                 }
344 344
             }
345
-            $String[] = '(' . implode(",", $value) . ')';
345
+            $String[] = '('.implode(",", $value).')';
346 346
         }
347 347
 
348
-        return "values" . implode(", ", $String);
348
+        return "values".implode(", ", $String);
349 349
     }
350 350
 
351 351
     /**
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
     {
357 357
         $String = [];
358 358
         foreach ($array as $column) {
359
-            $String[] = "`" . JsonExtractor::snakeCase($column['name']) . "`";
359
+            $String[] = "`".JsonExtractor::snakeCase($column['name'])."`";
360 360
         }
361 361
 
362 362
         return implode(",", $String);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         } elseif (empty($Data)) {
377 377
             return $empty_val;
378 378
         } else {
379
-            return (string)$Data;
379
+            return (string) $Data;
380 380
         }
381 381
     }
382 382
 }
Please login to merge, or discard this patch.
src/Helpers/Json.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function validate($json)
64 64
     {
65 65
         if (is_array($json)) {
66
-            return (object)[
66
+            return (object) [
67 67
                 $this->main_table_name => $json
68 68
             ];
69 69
         }
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
             $array = json_decode($array, true);
84 84
         }//if this is not the first time decode the text
85 85
 
86
-        $return_array = $array;//return array
86
+        $return_array = $array; //return array
87 87
 
88 88
         foreach ($array ?? [] as $key => $array_item) {
89 89
             if (!is_numeric($key) && $parent_table) {//single array table, no column
90
-                $table_name = $parent_table . '_' . $key;
90
+                $table_name = $parent_table.'_'.$key;
91 91
             } elseif ($parent_table) {//multiple array items
92 92
                 $table_name = $parent_table;
93 93
             } else {//first time loop
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
             }
96 96
 
97 97
             if (is_array($array_item)) {//if this is a array
98
-                $array_item = $this->addID($array_item, $table_name, $this->increment);//recursive the array
98
+                $array_item = $this->addID($array_item, $table_name, $this->increment); //recursive the array
99 99
                 if (empty($array_item['id']) && empty($array_item[0])) {//if this is a single array with no child
100
-                    $array_item = ['id' => $this->increment++] + $array_item;//add id
100
+                    $array_item = ['id' => $this->increment++] + $array_item; //add id
101 101
                 }
102 102
 
103 103
                 if (isset($array_item[0]) && !is_array($array_item[0]) && !is_object($array_item[0])) {//reference table
104 104
 
105 105
 
106
-                    $array_item = (object)array_map(function ($item) {
107
-                        return (object)[
106
+                    $array_item = (object) array_map(function($item) {
107
+                        return (object) [
108 108
                             'id' => $this->increment++,
109 109
                             'value'=>$item
110 110
                         ];
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $return_array = $array;
134 134
         foreach ($array ?? [] as $key => $array_item) {
135 135
             if (!is_numeric($key) && $parent_table) {//single array table, no column
136
-                $table_name = $parent_table . '_' . $key;
136
+                $table_name = $parent_table.'_'.$key;
137 137
             } elseif ($parent_table) {//multiple array items
138 138
                 $table_name = $parent_table;
139 139
             } elseif (!is_numeric($key)) {  //first time loop
Please login to merge, or discard this patch.