Completed
Push — master ( b250e3...e4d579 )
by Ivan
14:47
created
src/driver/oracle/Schema.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
         $columns = Collection::from($this
30 30
             ->query(
31 31
                 "SELECT * FROM all_tab_cols WHERE table_name = ? AND owner = ? and hidden_column = 'NO'",
32
-                [ strtoupper($table), $this->name() ]
32
+                [strtoupper($table), $this->name()]
33 33
             ))
34
-            ->map(function ($v) {
34
+            ->map(function($v) {
35 35
                 $new = [];
36 36
                 foreach ($v as $kk => $vv) {
37 37
                     $new[strtoupper($kk)] = $vv;
38 38
                 }
39 39
                 return $new;
40 40
             })
41
-            ->mapKey(function ($v) {
41
+            ->mapKey(function($v) {
42 42
                 return $v['COLUMN_NAME'];
43 43
             })
44
-            ->map(function ($v) {
44
+            ->map(function($v) {
45 45
                 $v['length'] = null;
46 46
                 if (!isset($v['DATA_TYPE'])) {
47 47
                     return $v;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
                     default:
54 54
                         if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
55 55
                             // extract length from varchar
56
-                            $v['length'] = (int)explode(')', (explode('(', $type)[1] ?? ''))[0];
56
+                            $v['length'] = (int) explode(')', (explode('(', $type)[1] ?? ''))[0];
57 57
                             $v['length'] = $v['length'] > 0 ? $v['length'] : null;
58 58
                         }
59 59
                         break;
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
             ->query(
70 70
                 "SELECT constraint_name FROM all_constraints
71 71
                 WHERE table_name = ? AND constraint_type = ? AND owner = ?",
72
-                [ strtoupper($table), 'P', $owner ]
72
+                [strtoupper($table), 'P', $owner]
73 73
             ))
74
-            ->map(function ($v) {
74
+            ->map(function($v) {
75 75
                 $new = [];
76 76
                 foreach ($v as $kk => $vv) {
77 77
                     $new[strtoupper($kk)] = $vv;
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
                 ->query(
87 87
                     "SELECT column_name FROM all_cons_columns
88 88
                     WHERE table_name = ? AND constraint_name = ? AND owner = ?",
89
-                    [ strtoupper($table), $pkname, $owner ]
89
+                    [strtoupper($table), $pkname, $owner]
90 90
                 ))
91
-                ->map(function ($v) {
91
+                ->map(function($v) {
92 92
                     $new = [];
93 93
                     foreach ($v as $kk => $vv) {
94 94
                         $new[strtoupper($kk)] = $vv;
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
                     LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
116 116
                     WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.R_CONSTRAINT_NAME = ? AND ac.CONSTRAINT_TYPE = ?
117 117
                     ORDER BY cc.POSITION",
118
-                    [ $owner, $owner, $pkname, 'R' ]
118
+                    [$owner, $owner, $pkname, 'R']
119 119
                 ))
120
-                ->map(function ($v) {
120
+                ->map(function($v) {
121 121
                     $new = [];
122 122
                     foreach ($v as $kk => $vv) {
123 123
                         $new[strtoupper($kk)] = $vv;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                  as $relation
128 128
             ) {
129 129
                 $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME'];
130
-                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] =
130
+                $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] =
131 131
                     $relation['COLUMN_NAME'];
132 132
             }
133 133
             foreach ($relations as $data) {
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
                                 ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND
158 158
                                 cc.COLUMN_NAME IN (??)
159 159
                             ORDER BY POSITION",
160
-                            [ $owner, $owner, $data['table'], 'R', $columns ]
160
+                            [$owner, $owner, $data['table'], 'R', $columns]
161 161
                         ))
162
-                        ->map(function ($v) {
162
+                        ->map(function($v) {
163 163
                             $new = [];
164 164
                             foreach ($v as $kk => $vv) {
165 165
                                 $new[strtoupper($kk)] = $vv;
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
                         ->query(
180 180
                             "SELECT COLUMN_NAME FROM all_cons_columns
181 181
                              WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION",
182
-                            [ $owner, current($foreign['keymap']) ]
182
+                            [$owner, current($foreign['keymap'])]
183 183
                         ))
184
-                        ->map(function ($v) {
184
+                        ->map(function($v) {
185 185
                             $new = [];
186 186
                             foreach ($v as $kk => $vv) {
187 187
                                 $new[strtoupper($kk)] = $vv;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                     $relname = $foreign['table'];
197 197
                     $cntr = 1;
198 198
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
199
-                        $relname = $foreign['table'] . '_' . (++ $cntr);
199
+                        $relname = $foreign['table'].'_'.(++$cntr);
200 200
                     }
201 201
                     $definition->addRelation(
202 202
                         new TableRelation(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                     $relname = $data['table'];
213 213
                     $cntr = 1;
214 214
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
215
-                        $relname = $data['table'] . '_' . (++ $cntr);
215
+                        $relname = $data['table'].'_'.(++$cntr);
216 216
                     }
217 217
                     $definition->addRelation(
218 218
                         new TableRelation(
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
                     LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME
241 241
                     WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ?
242 242
                     ORDER BY cc.POSITION",
243
-                    [ $owner, $owner, strtoupper($table), 'R' ]
243
+                    [$owner, $owner, strtoupper($table), 'R']
244 244
                 ))
245
-                ->map(function ($v) {
245
+                ->map(function($v) {
246 246
                     $new = [];
247 247
                     foreach ($v as $kk => $vv) {
248 248
                         $new[strtoupper($kk)] = $vv;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
                     ->query(
261 261
                         "SELECT COLUMN_NAME FROM all_cons_columns
262 262
                          WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION",
263
-                        [ $owner, current($data['keymap']) ]
263
+                        [$owner, current($data['keymap'])]
264 264
                     ))
265
-                    ->map(function ($v) {
265
+                    ->map(function($v) {
266 266
                         $new = [];
267 267
                         foreach ($v as $kk => $vv) {
268 268
                             $new[strtoupper($kk)] = $vv;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 $relname = $data['table'];
278 278
                 $cntr = 1;
279 279
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
280
-                    $relname = $data['table'] . '_' . (++ $cntr);
280
+                    $relname = $data['table'].'_'.(++$cntr);
281 281
                 }
282 282
                 $definition->addRelation(
283 283
                     new TableRelation(
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
                 "SELECT TABLE_NAME FROM ALL_TABLES where OWNER = ?",
299 299
                 [$this->connection['name']]
300 300
             ))
301
-            ->map(function ($v) {
301
+            ->map(function($v) {
302 302
                 $new = [];
303 303
                 foreach ($v as $kk => $vv) {
304 304
                     $new[strtoupper($kk)] = $vv;
305 305
                 }
306 306
                 return $new;
307 307
             })
308
-            ->mapKey(function ($v) {
308
+            ->mapKey(function($v) {
309 309
                 return strtolower($v['TABLE_NAME']);
310 310
             })
311 311
             ->pluck('TABLE_NAME')
312
-            ->map(function ($v) {
312
+            ->map(function($v) {
313 313
                 return $this->table($v)->toLowerCase();
314 314
             })
315 315
             ->toArray();
Please login to merge, or discard this patch.
src/driver/postgre/Schema.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
             $table = $temp[1];
30 30
         }
31 31
 
32
-        if (isset($tables[$schema . '.' . $table])) {
33
-            return $tables[$schema . '.' . $table];
32
+        if (isset($tables[$schema.'.'.$table])) {
33
+            return $tables[$schema.'.'.$table];
34 34
         }
35 35
 
36 36
         static $relationsT = null;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                         (kc.table_schema = ? OR ct.table_schema = ?) AND
62 62
                         kc.table_name IS NOT NULL AND
63 63
                         kc.position_in_unique_constraint IS NOT NULL",
64
-                    [ $catalog, $main, $main ]
64
+                    [$catalog, $main, $main]
65 65
                 )
66 66
             )->toArray();
67 67
             foreach ($col as $row) {
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
                 if ($row['referenced_table_schema'] !== $main) {
72 72
                     $additional[] = $row['referenced_table_schema'];
73 73
                 }
74
-                $relationsT[$row['table_schema'] . '.' . $row['table_name']][] = $row;
75
-                $relationsR[$row['referenced_table_schema'] . '.' . $row['referenced_table_name']][] = $row;
74
+                $relationsT[$row['table_schema'].'.'.$row['table_name']][] = $row;
75
+                $relationsR[$row['referenced_table_schema'].'.'.$row['referenced_table_name']][] = $row;
76 76
             }
77 77
             foreach (array_filter(array_unique($additional)) as $s) {
78 78
                 $col = Collection::from(
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
                             (kc.table_schema = ? AND ct.table_schema = ?) AND
98 98
                             kc.table_name IS NOT NULL AND
99 99
                             kc.position_in_unique_constraint IS NOT NULL",
100
-                        [ $catalog, $s, $s ]
100
+                        [$catalog, $s, $s]
101 101
                     )
102 102
                 )->toArray();
103 103
                 foreach ($col as $row) {
104
-                    $relationsT[$row['table_schema'] . '.' . $row['table_name']][] = $row;
105
-                    $relationsR[$row['referenced_table_schema'] . '.' . $row['referenced_table_name']][] = $row;
104
+                    $relationsT[$row['table_schema'].'.'.$row['table_name']][] = $row;
105
+                    $relationsR[$row['referenced_table_schema'].'.'.$row['referenced_table_name']][] = $row;
106 106
                 }
107 107
             }
108 108
         }
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
         $columns = Collection::from($this
111 111
             ->query(
112 112
                 "SELECT * FROM information_schema.columns WHERE table_name = ? AND table_schema = ? AND table_catalog = ?",
113
-                [ $table, $schema, $catalog ]
113
+                [$table, $schema, $catalog]
114 114
             ))
115
-            ->mapKey(function ($v) {
115
+            ->mapKey(function($v) {
116 116
                 return $v['column_name'];
117 117
             })
118
-            ->map(function ($v) {
118
+            ->map(function($v) {
119 119
                 $v['length'] = null;
120 120
                 if (!isset($v['data_type'])) {
121 121
                     return $v;
@@ -123,20 +123,20 @@  discard block
 block discarded – undo
123 123
                 switch ($v['data_type']) {
124 124
                     case 'character':
125 125
                     case 'character varying':
126
-                        $v['length'] = (int)$v['character_maximum_length'];
126
+                        $v['length'] = (int) $v['character_maximum_length'];
127 127
                         break;
128 128
                 }
129 129
                 return $v;
130 130
             })
131 131
             ->toArray();
132 132
         if (!count($columns)) {
133
-            throw new DBException('Table not found by name: ' . implode('.', [$schema,$table]));
133
+            throw new DBException('Table not found by name: '.implode('.', [$schema, $table]));
134 134
         }
135 135
         $pkname = Collection::from($this
136 136
             ->query(
137 137
                 "SELECT constraint_name FROM information_schema.table_constraints
138 138
                 WHERE table_name = ? AND constraint_type = ? AND table_schema = ? AND table_catalog = ?",
139
-                [ $table, 'PRIMARY KEY', $schema, $catalog ]
139
+                [$table, 'PRIMARY KEY', $schema, $catalog]
140 140
             ))
141 141
             ->pluck('constraint_name')
142 142
             ->value();
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
                 ->query(
147 147
                     "SELECT column_name FROM information_schema.constraint_column_usage
148 148
                      WHERE table_name = ? AND constraint_name = ? AND table_schema = ? AND table_catalog = ?",
149
-                    [ $table, $pkname, $schema, $catalog ]
149
+                    [$table, $pkname, $schema, $catalog]
150 150
                 ))
151 151
                 ->pluck('column_name')
152 152
                 ->toArray();
153 153
         }
154
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
154
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
155 155
             ->addColumns($columns)
156 156
             ->setPrimaryKey($primary)
157 157
             ->setComment('');
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
             // assuming current table is on the "one" end having "many" records in the referencing table
162 162
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
163 163
             $relations = [];
164
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
165
-                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'] . '.' . $relation['table_name'];
164
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
165
+                $relations[$relation['constraint_name']]['table'] = $relation['table_schema'].'.'.$relation['table_name'];
166 166
                 $relations[$relation['constraint_name']]['keymap'][$relation['referenced_column_name']] =
167 167
                     $relation['column_name'];
168 168
             }
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
                 $usedcol = [];
179 179
                 if (count($columns)) {
180 180
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
181
-                        ->filter(function ($v) use ($columns) {
181
+                        ->filter(function($v) use ($columns) {
182 182
                             return in_array($v['column_name'], $columns);
183 183
                         }) as $relation
184 184
                     ) {
185
-                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' . $relation['referenced_table_name'];
185
+                        $foreign[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.$relation['referenced_table_name'];
186 186
                         $foreign[$relation['constraint_name']]['keymap'][$relation['column_name']] =
187 187
                             $relation['referenced_column_name'];
188 188
                         $usedcol[] = $relation['column_name'];
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                         $definition->getName() == $relname ||
203 203
                         $definition->getColumn($relname)
204 204
                     ) {
205
-                        $relname = $orig . '_' . (++ $cntr);
205
+                        $relname = $orig.'_'.(++$cntr);
206 206
                     }
207 207
                     $definition->addRelation(
208 208
                         new TableRelation(
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                         $definition->getName() == $relname ||
228 228
                         $definition->getColumn($relname)
229 229
                     ) {
230
-                        $relname = $orig . '_' . (++ $cntr);
230
+                        $relname = $orig.'_'.(++$cntr);
231 231
                     }
232 232
                     $definition->addRelation(
233 233
                         new TableRelation(
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
             // assuming current table is linked to "one" record in the referenced table
244 244
             // resulting in a "belongsTo" relationship
245 245
             $relations = [];
246
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
247
-                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'] . '.' . $relation['referenced_table_name'];
246
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
247
+                $relations[$relation['constraint_name']]['table'] = $relation['referenced_table_schema'].'.'.$relation['referenced_table_name'];
248 248
                 $relations[$relation['constraint_name']]['keymap'][$relation['column_name']] =
249 249
                     $relation['referenced_column_name'];
250 250
             }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                     $definition->getName() == $relname ||
262 262
                     $definition->getColumn($relname)
263 263
                 ) {
264
-                    $relname = $orig . '_' . (++ $cntr);
264
+                    $relname = $orig.'_'.(++$cntr);
265 265
                 }
266 266
                 $definition->addRelation(
267 267
                     new TableRelation(
@@ -280,19 +280,19 @@  discard block
 block discarded – undo
280 280
         $tables = Collection::from($this
281 281
             ->query(
282 282
                 "SELECT table_name FROM information_schema.tables where table_schema = ? AND table_catalog = ?",
283
-                [ $this->connection['opts']['schema'] ?? 'public', $this->connection['name'] ]
283
+                [$this->connection['opts']['schema'] ?? 'public', $this->connection['name']]
284 284
             ))
285
-            ->mapKey(function ($v) {
285
+            ->mapKey(function($v) {
286 286
                 return strtolower($v['table_name']);
287 287
             })
288 288
             ->pluck('table_name')
289
-            ->map(function ($v) {
289
+            ->map(function($v) {
290 290
                 return $this->table($v)->toLowerCase();
291 291
             })
292 292
             ->toArray();
293 293
 
294 294
         foreach (array_keys($tables) as $k) {
295
-            $tables[($this->connection['opts']['schema'] ?? 'public') . '.' . $k] = &$tables[$k];
295
+            $tables[($this->connection['opts']['schema'] ?? 'public').'.'.$k] = &$tables[$k];
296 296
         }
297 297
         return $tables;
298 298
     }
Please login to merge, or discard this patch.
src/driver/mysql/Schema.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
             $table = $temp[1];
28 28
         }
29 29
 
30
-        if (isset($tables[$schema . '.' . $table])) {
31
-            return $tables[$schema . '.' . $table];
30
+        if (isset($tables[$schema.'.'.$table])) {
31
+            return $tables[$schema.'.'.$table];
32 32
         }
33 33
 
34 34
         static $comments = [];
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
             $comments[$schema] = Collection::from(
37 37
                 $this->query(
38 38
                     "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?",
39
-                    [ $schema ]
39
+                    [$schema]
40 40
                 )
41 41
             )
42
-            ->mapKey(function (array $v): string {
42
+            ->mapKey(function(array $v): string {
43 43
                 return $v['TABLE_NAME'];
44 44
             })
45 45
             ->pluck('TABLE_COMMENT')
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                      WHERE
60 60
                         (TABLE_SCHEMA = ? OR REFERENCED_TABLE_SCHEMA = ?) AND
61 61
                         TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
62
-                    [ $main, $main ]
62
+                    [$main, $main]
63 63
                 )
64 64
             )->toArray();
65 65
             foreach ($col as $row) {
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
                 if ($row['REFERENCED_TABLE_SCHEMA'] !== $main) {
70 70
                     $additional[] = $row['REFERENCED_TABLE_SCHEMA'];
71 71
                 }
72
-                $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
73
-                $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
72
+                $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
73
+                $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
74 74
             }
75 75
             foreach (array_filter(array_unique($additional)) as $s) {
76 76
                 $col = Collection::from(
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
                         WHERE
81 81
                             TABLE_SCHEMA = ? AND REFERENCED_TABLE_SCHEMA = ? AND
82 82
                             TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
83
-                        [ $s, $s ]
83
+                        [$s, $s]
84 84
                     )
85 85
                 )->toArray();
86 86
                 foreach ($col as $row) {
87
-                    $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
88
-                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
87
+                    $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
88
+                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
89 89
                 }
90 90
             }
91 91
         }
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
         if (!count($columns)) {
95 95
             throw new DBException('Table not found by name');
96 96
         }
97
-        $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema))
97
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
98 98
             ->addColumns(
99 99
                 $columns
100 100
                     ->clone()
101
-                    ->mapKey(function (array $v): string {
101
+                    ->mapKey(function(array $v): string {
102 102
                         return $v['Field'];
103 103
                     })
104
-                    ->map(function (array $v): array {
104
+                    ->map(function(array $v): array {
105 105
                         $v['length'] = null;
106 106
                         if (!isset($v['Type'])) {
107 107
                             return $v;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                             default:
124 124
                                 if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
125 125
                                     // extract length from varchar
126
-                                    $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
126
+                                    $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
127 127
                                     $v['length'] = $v['length'] > 0 ? $v['length'] : null;
128 128
                                 }
129 129
                                 break;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             ->setPrimaryKey(
136 136
                 $columns
137 137
                     ->clone()
138
-                    ->filter(function (array $v): bool {
138
+                    ->filter(function(array $v): bool {
139 139
                         return $v['Key'] === 'PRI';
140 140
                     })
141 141
                     ->pluck('Field')
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
             // assuming current table is on the "one" end having "many" records in the referencing table
150 150
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
151 151
             $relations = [];
152
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
153
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' . $relation['TABLE_NAME'];
152
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
153
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.$relation['TABLE_NAME'];
154 154
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
155 155
                     $relation['COLUMN_NAME'];
156 156
             }
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
                 $usedcol = [];
167 167
                 if (count($columns)) {
168 168
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
169
-                        ->filter(function (array $v) use ($columns): bool {
169
+                        ->filter(function(array $v) use ($columns): bool {
170 170
                             return in_array($v['COLUMN_NAME'], $columns);
171 171
                         })
172
-                        ->map(function (array $v): array {
172
+                        ->map(function(array $v): array {
173 173
                             $new = [];
174 174
                             foreach ($v as $kk => $vv) {
175 175
                                 $new[strtoupper($kk)] = $vv;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                             return $new;
178 178
                         }) as $relation
179 179
                     ) {
180
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . $relation['REFERENCED_TABLE_NAME'];
180
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.$relation['REFERENCED_TABLE_NAME'];
181 181
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
182 182
                             $relation['REFERENCED_COLUMN_NAME'];
183 183
                         $usedcol[] = $relation['COLUMN_NAME'];
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                     $orig = $relname;
194 194
                     $cntr = 1;
195 195
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
196
-                        $relname = $orig . '_' . (++ $cntr);
196
+                        $relname = $orig.'_'.(++$cntr);
197 197
                     }
198 198
                     $definition->addRelation(
199 199
                         new TableRelation(
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                     $orig = $relname;
215 215
                     $cntr = 1;
216 216
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
217
-                        $relname = $orig . '_' . (++ $cntr);
217
+                        $relname = $orig.'_'.(++$cntr);
218 218
                     }
219 219
                     $definition->addRelation(
220 220
                         new TableRelation(
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
             // assuming current table is linked to "one" record in the referenced table
231 231
             // resulting in a "belongsTo" relationship
232 232
             $relations = [];
233
-            foreach (Collection::from($relationsT[$schema . '.' . $table] ?? [])
234
-                ->map(function (array $v): array {
233
+            foreach (Collection::from($relationsT[$schema.'.'.$table] ?? [])
234
+                ->map(function(array $v): array {
235 235
                     $new = [];
236 236
                     foreach ($v as $kk => $vv) {
237 237
                         $new[strtoupper($kk)] = $vv;
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                     return $new;
240 240
                 }) as $relation
241 241
             ) {
242
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . $relation['REFERENCED_TABLE_NAME'];
242
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.$relation['REFERENCED_TABLE_NAME'];
243 243
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
244 244
                     $relation['REFERENCED_COLUMN_NAME'];
245 245
             }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                 $orig = $relname;
253 253
                 $cntr = 1;
254 254
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
255
-                    $relname = $orig . '_' . (++ $cntr);
255
+                    $relname = $orig.'_'.(++$cntr);
256 256
                 }
257 257
                 $definition->addRelation(
258 258
                     new TableRelation(
@@ -273,23 +273,23 @@  discard block
 block discarded – undo
273 273
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
274 274
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
275 275
             ))
276
-            ->map(function (array $v): array {
276
+            ->map(function(array $v): array {
277 277
                 $new = [];
278 278
                 foreach ($v as $kk => $vv) {
279 279
                     $new[strtoupper($kk)] = $vv;
280 280
                 }
281 281
                 return $new;
282 282
             })
283
-            ->mapKey(function (array $v): string {
283
+            ->mapKey(function(array $v): string {
284 284
                 return strtolower($v['TABLE_NAME']);
285 285
             })
286 286
             ->pluck('TABLE_NAME')
287
-            ->map(function (string $v): Table {
287
+            ->map(function(string $v): Table {
288 288
                 return $this->table($v)->toLowerCase();
289 289
             })
290 290
             ->toArray();
291 291
         foreach (array_keys($tables) as $k) {
292
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
292
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
293 293
         }
294 294
         return $tables;
295 295
     }
Please login to merge, or discard this patch.