@@ -46,7 +46,7 @@ |
||
| 46 | 46 | public function validate($json) |
| 47 | 47 | { |
| 48 | 48 | if (is_array($json)) { |
| 49 | - return (object)[ |
|
| 49 | + return (object) [ |
|
| 50 | 50 | $this->main_table_name=>$json |
| 51 | 51 | ]; |
| 52 | 52 | } |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | { |
| 77 | 77 | foreach ($JsonExtractor->getTablesArray() as $TableName => $TableColumn) { |
| 78 | 78 | $this->capsule::schema()->dropIfExists($TableName); |
| 79 | - $this->capsule::schema()->create($TableName, function ($table) use ($TableColumn) { |
|
| 79 | + $this->capsule::schema()->create($TableName, function($table) use ($TableColumn) { |
|
| 80 | 80 | foreach ($TableColumn as $column_item) { |
| 81 | 81 | switch ($column_item['type']) { |
| 82 | 82 | case 'int': |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | if (is_array($value) && is_object($value[0])) {//check whether it's a array and it's firs element is a object |
| 65 | 65 | |
| 66 | - $table_data = $this->getTable($prefix . $table_name, $value);//get table sql |
|
| 66 | + $table_data = $this->getTable($prefix.$table_name, $value); //get table sql |
|
| 67 | 67 | $this->table[$table_data['name']] = $table_data['column']; |
| 68 | 68 | |
| 69 | - $this->toMysqlTables($this->getHighestColumnArray($value), $prefix . $table_name . '_');//get it inside tables |
|
| 69 | + $this->toMysqlTables($this->getHighestColumnArray($value), $prefix.$table_name.'_'); //get it inside tables |
|
| 70 | 70 | } elseif (is_array($value) || is_object($value)) {//if it's a array and firs element is not a object |
| 71 | 71 | |
| 72 | - $table_data = $this->getTable($prefix . $table_name, $value); |
|
| 72 | + $table_data = $this->getTable($prefix.$table_name, $value); |
|
| 73 | 73 | $this->table[$table_data['name']] = $table_data['column']; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | foreach ($data as $table_name => $value) { |
| 89 | 89 | if ($this->snake_case_table) { |
| 90 | - $table_name = $this->snakeCase($prefix . $table_name); |
|
| 90 | + $table_name = $this->snakeCase($prefix.$table_name); |
|
| 91 | 91 | } |
| 92 | 92 | if (is_array($value) && is_object($value[0])) {//if it's a array and firs element is not a object |
| 93 | - $this->toMysqlData($value, $table_name . '_'); |
|
| 93 | + $this->toMysqlData($value, $table_name.'_'); |
|
| 94 | 94 | } elseif (is_object($value) || is_array($value)) { |
| 95 | - $this->toMysqlData($value, $table_name . '_'); |
|
| 95 | + $this->toMysqlData($value, $table_name.'_'); |
|
| 96 | 96 | $this->getTableData($table_name, $value); |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $DataItem[] = ['value' => $item_value]; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $this->data[$table_name] = array_merge(($this->data[$table_name]??[]), $DataItem); |
|
| 129 | + $this->data[$table_name] = array_merge(($this->data[$table_name]??[]), $DataItem); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | if ($this->snake_case_column) { |
| 157 | 157 | return [ |
| 158 | 158 | 'name' => $table, |
| 159 | - 'column' => array_map(function ($item) { |
|
| 159 | + 'column' => array_map(function($item) { |
|
| 160 | 160 | return [ |
| 161 | 161 | 'name' => $this->snakeCase($item['name']), |
| 162 | 162 | 'type' => $item['type'] |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | } elseif (is_numeric($item)) { |
| 325 | 325 | $value[] = $item; |
| 326 | 326 | } else { |
| 327 | - $value[] = '"' . addcslashes($item, "W") . '"'; |
|
| 327 | + $value[] = '"'.addcslashes($item, "W").'"'; |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | - $String[] = '(' . implode(",", $value) . ')'; |
|
| 330 | + $String[] = '('.implode(",", $value).')'; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - return "values" . implode(", ", $String); |
|
| 333 | + return "values".implode(", ", $String); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | { |
| 342 | 342 | $String = []; |
| 343 | 343 | foreach ($array as $column) { |
| 344 | - $String[] = "`" . JsonExtractor::snakeCase($column['name']) . "`"; |
|
| 344 | + $String[] = "`".JsonExtractor::snakeCase($column['name'])."`"; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | return implode(",", $String); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | } elseif (empty($Data)) { |
| 362 | 362 | return $empty_val; |
| 363 | 363 | } else { |
| 364 | - return (string)$Data; |
|
| 364 | + return (string) $Data; |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | } |