Completed
Push — master ( bbde74...290f10 )
by Ivan
13:51
created
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')
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                      WHERE
62 62
                         (TABLE_SCHEMA = ? OR REFERENCED_TABLE_SCHEMA = ?) AND
63 63
                         TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
64
-                    [ $main, $main ]
64
+                    [$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(
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
                         WHERE
85 85
                             TABLE_SCHEMA = ? AND REFERENCED_TABLE_SCHEMA = ? AND
86 86
                             TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL",
87
-                        [ $s, $s ]
87
+                        [$s, $s]
88 88
                     )
89 89
                 )->toArray();
90 90
                 foreach ($col as $row) {
91
-                    $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row;
92
-                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row;
91
+                    $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row;
92
+                    $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row;
93 93
                 }
94 94
             }
95 95
         }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
         if (!count($columns)) {
99 99
             throw new DBException('Table not found by name');
100 100
         }
101
-        $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema))
101
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
102 102
             ->addColumns(
103 103
                 $columns
104 104
                     ->clone()
105
-                    ->mapKey(function (array $v): string {
105
+                    ->mapKey(function(array $v): string {
106 106
                         return $v['Field'];
107 107
                     })
108
-                    ->map(function (array $v): array {
108
+                    ->map(function(array $v): array {
109 109
                         $v['length'] = null;
110 110
                         if (!isset($v['Type'])) {
111 111
                             return $v;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                             default:
128 128
                                 if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
129 129
                                     // extract length from varchar
130
-                                    $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
130
+                                    $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
131 131
                                     $v['length'] = $v['length'] > 0 ? $v['length'] : null;
132 132
                                 }
133 133
                                 break;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             ->setPrimaryKey(
140 140
                 $columns
141 141
                     ->clone()
142
-                    ->filter(function (array $v): bool {
142
+                    ->filter(function(array $v): bool {
143 143
                         return $v['Key'] === 'PRI';
144 144
                     })
145 145
                     ->pluck('Field')
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             // assuming current table is on the "one" end having "many" records in the referencing table
154 154
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
155 155
             $relations = [];
156
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) {
157
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' .
156
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) {
157
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'.
158 158
                     $relation['TABLE_NAME'];
159 159
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] =
160 160
                     $relation['COLUMN_NAME'];
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
                 $usedcol = [];
172 172
                 if (count($columns)) {
173 173
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
174
-                        ->filter(function (array $v) use ($columns): bool {
174
+                        ->filter(function(array $v) use ($columns): bool {
175 175
                             return in_array($v['COLUMN_NAME'], $columns);
176 176
                         })
177
-                        ->map(function (array $v): array {
177
+                        ->map(function(array $v): array {
178 178
                             $new = [];
179 179
                             foreach ($v as $kk => $vv) {
180 180
                                 $new[strtoupper($kk)] = $vv;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                             return $new;
183 183
                         }) as $relation
184 184
                     ) {
185
-                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
185
+                        $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
186 186
                             $relation['REFERENCED_TABLE_NAME'];
187 187
                         $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
188 188
                             $relation['REFERENCED_COLUMN_NAME'];
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $orig = $relname;
200 200
                     $cntr = 1;
201 201
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
202
-                        $relname = $orig . '_' . (++ $cntr);
202
+                        $relname = $orig.'_'.(++$cntr);
203 203
                     }
204 204
                     $definition->addRelation(
205 205
                         new TableRelation(
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                     $orig = $relname;
221 221
                     $cntr = 1;
222 222
                     while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
223
-                        $relname = $orig . '_' . (++ $cntr);
223
+                        $relname = $orig.'_'.(++$cntr);
224 224
                     }
225 225
                     $definition->addRelation(
226 226
                         new TableRelation(
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
             // assuming current table is linked to "one" record in the referenced table
237 237
             // resulting in a "belongsTo" relationship
238 238
             $relations = [];
239
-            foreach (Collection::from($relationsT[$schema . '.' . $table] ?? [])
240
-                ->map(function (array $v): array {
239
+            foreach (Collection::from($relationsT[$schema.'.'.$table] ?? [])
240
+                ->map(function(array $v): array {
241 241
                     $new = [];
242 242
                     foreach ($v as $kk => $vv) {
243 243
                         $new[strtoupper($kk)] = $vv;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     return $new;
246 246
                 }) as $relation
247 247
             ) {
248
-                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' .
248
+                $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'.
249 249
                     $relation['REFERENCED_TABLE_NAME'];
250 250
                 $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] =
251 251
                     $relation['REFERENCED_COLUMN_NAME'];
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                 $orig = $relname;
260 260
                 $cntr = 1;
261 261
                 while ($definition->hasRelation($relname) || $definition->getName() == $relname) {
262
-                    $relname = $orig . '_' . (++ $cntr);
262
+                    $relname = $orig.'_'.(++$cntr);
263 263
                 }
264 264
                 $definition->addRelation(
265 265
                     new TableRelation(
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
                 "SELECT table_name FROM information_schema.tables where table_schema = ?",
281 281
                 [$this->connection['opts']['schema'] ?? $this->connection['name']]
282 282
             ))
283
-            ->map(function (array $v): array {
283
+            ->map(function(array $v): array {
284 284
                 $new = [];
285 285
                 foreach ($v as $kk => $vv) {
286 286
                     $new[strtoupper($kk)] = $vv;
287 287
                 }
288 288
                 return $new;
289 289
             })
290
-            ->mapKey(function (array $v): string {
290
+            ->mapKey(function(array $v): string {
291 291
                 return strtolower($v['TABLE_NAME']);
292 292
             })
293 293
             ->pluck('TABLE_NAME')
294
-            ->map(function (string $v): Table {
294
+            ->map(function(string $v): Table {
295 295
                 return $this->table($v)->toLowerCase();
296 296
             })
297 297
             ->toArray();
298 298
         foreach (array_keys($tables) as $k) {
299
-            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k];
299
+            $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k];
300 300
         }
301 301
         return $tables;
302 302
     }
Please login to merge, or discard this patch.
src/Schema.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     
65 65
     public function toArray(): array
66 66
     {
67
-        return array_map(function ($table) {
67
+        return array_map(function($table) {
68 68
             return [
69 69
                 'name' => $table->getName(),
70 70
                 'schema' => $table->getSchema(),
71 71
                 'pkey' => $table->getPrimaryKey(),
72 72
                 'comment' => $table->getComment(),
73
-                'columns' => array_map(function ($column) {
73
+                'columns' => array_map(function($column) {
74 74
                     return [
75 75
                         'name' => $column->getName(),
76 76
                         'type' => $column->getType(),
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
                         'nullable' => $column->isNullable()
82 82
                     ];
83 83
                 }, $table->getFullColumns()),
84
-                'relations' => array_map(function ($rel) {
84
+                'relations' => array_map(function($rel) {
85 85
                     $relation = clone $rel;
86
-                    $relation = (array)$relation;
86
+                    $relation = (array) $relation;
87 87
                     $relation['table'] = $rel->table->getName();
88 88
                     if ($rel->pivot) {
89 89
                         $relation['pivot'] = $rel->pivot->getName();
Please login to merge, or discard this patch.
src/driver/postgre/Statement.php 1 patch
Spacing   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
         if (strpos(strtolower($statement), 'prepare') === 0) {
24 24
             $this->drv->raw($this->statement);
25 25
             if (!isset($this->name)) {
26
-                $this->name = trim((preg_split('(\s+)', trim($this->statement))?:[])[1]??'', '"');
26
+                $this->name = trim((preg_split('(\s+)', trim($this->statement)) ?: [])[1] ?? '', '"');
27 27
             }
28 28
         } elseif ($this->name !== null) {
29 29
             $temp = \pg_prepare($this->driver, $this->name, $this->statement);
30 30
             if (!$temp) {
31 31
                 $log = $this->drv->option('log_file');
32
-                if ($log && (int)$this->drv->option('log_errors', 1)) {
32
+                if ($log && (int) $this->drv->option('log_errors', 1)) {
33 33
                     @file_put_contents(
34 34
                         $log,
35
-                        '--' . date('Y-m-d H:i:s') . ' ERROR PREPARING: ' . \pg_last_error($this->driver) . "\r\n" .
36
-                        $this->statement . "\r\n" .
35
+                        '--'.date('Y-m-d H:i:s').' ERROR PREPARING: '.\pg_last_error($this->driver)."\r\n".
36
+                        $this->statement."\r\n".
37 37
                         "\r\n",
38 38
                         FILE_APPEND
39 39
                     );
@@ -62,22 +62,20 @@  discard block
 block discarded – undo
62 62
         try {
63 63
             if ($this->name !== null) {
64 64
                 $temp = (is_array($data) && count($data)) ?
65
-                    \pg_execute($this->driver, $this->name, $data) :
66
-                    \pg_execute($this->driver, $this->name, array());
65
+                    \pg_execute($this->driver, $this->name, $data) : \pg_execute($this->driver, $this->name, array());
67 66
             } else {
68 67
                 $temp = (is_array($data) && count($data)) ?
69
-                    \pg_query_params($this->driver, $this->statement, $data) :
70
-                    \pg_query_params($this->driver, $this->statement, array());
68
+                    \pg_query_params($this->driver, $this->statement, $data) : \pg_query_params($this->driver, $this->statement, array());
71 69
             }
72 70
         } catch (\Exception $e) {
73 71
             $temp = false;
74 72
         }
75 73
         if (!$temp) {
76
-            if ($log && (int)$this->drv->option('log_errors', 1)) {
74
+            if ($log && (int) $this->drv->option('log_errors', 1)) {
77 75
                 @file_put_contents(
78 76
                     $log,
79
-                    '--' . date('Y-m-d H:i:s') . ' ERROR: ' . \pg_last_error($this->driver) . "\r\n" .
80
-                    $this->statement . "\r\n" .
77
+                    '--'.date('Y-m-d H:i:s').' ERROR: '.\pg_last_error($this->driver)."\r\n".
78
+                    $this->statement."\r\n".
81 79
                     "\r\n",
82 80
                     FILE_APPEND
83 81
                 );
@@ -86,11 +84,11 @@  discard block
 block discarded – undo
86 84
         }
87 85
         if ($log) {
88 86
             $tm = microtime(true) - $tm;
89
-            if ($tm >= (float)$this->drv->option('log_slow', 0)) {
87
+            if ($tm >= (float) $this->drv->option('log_slow', 0)) {
90 88
                 @file_put_contents(
91 89
                     $log,
92
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
93
-                    $this->statement . "\r\n" .
90
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
91
+                    $this->statement."\r\n".
94 92
                     "\r\n",
95 93
                     FILE_APPEND
96 94
                 );
Please login to merge, or discard this patch.
src/driver/mysql/Statement.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             foreach ($lng as $index) {
78 78
                 if (is_resource($data[$index]) && get_resource_type($data[$index]) === 'stream') {
79 79
                     while (!feof($data[$index])) {
80
-                        $this->statement->send_long_data($index, (string)fread($data[$index], $lds));
80
+                        $this->statement->send_long_data($index, (string) fread($data[$index], $lds));
81 81
                     }
82 82
                 } else {
83 83
                     $data[$index] = str_split($data[$index], $lds);
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
             $res = false;
98 98
         }
99 99
         if (!$res) {
100
-            if ($log && (int)$this->driver->option('log_errors', 1)) {
100
+            if ($log && (int) $this->driver->option('log_errors', 1)) {
101 101
                 @file_put_contents(
102 102
                     $log,
103
-                    '--' . date('Y-m-d H:i:s') . ' ERROR: ' . $this->statement->error . "\r\n" .
104
-                    $this->sql . "\r\n" .
103
+                    '--'.date('Y-m-d H:i:s').' ERROR: '.$this->statement->error."\r\n".
104
+                    $this->sql."\r\n".
105 105
                     "\r\n",
106 106
                     FILE_APPEND
107 107
                 );
108 108
             }
109
-            throw new DBException('Prepared execute error: ' . $this->statement->error);
109
+            throw new DBException('Prepared execute error: '.$this->statement->error);
110 110
         }
111 111
         if ($log) {
112 112
             $tm = microtime(true) - $tm;
113
-            if ($tm >= (float)$this->driver->option('log_slow', 0)) {
113
+            if ($tm >= (float) $this->driver->option('log_slow', 0)) {
114 114
                 @file_put_contents(
115 115
                     $log,
116
-                    '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" .
117
-                    $this->sql . "\r\n" .
116
+                    '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n".
117
+                    $this->sql."\r\n".
118 118
                     "\r\n",
119 119
                     FILE_APPEND
120 120
                 );
Please login to merge, or discard this patch.
src/driver/sqlite/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         if ($this->lnk === null) {
39 39
             try {
40 40
                 $this->lnk = new \SQLite3($this->connection['name']);
41
-                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8') . '"');
41
+                $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8').'"');
42 42
             } catch (\Exception $e) {
43 43
                 if ($this->lnk !== null) {
44 44
                     throw new DBException('Connect error: '.$this->lnk->lastErrorMsg());
Please login to merge, or discard this patch.
src/schema/TableColumn.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $instance->setNullable($data['nullable']);
43 43
         }
44 44
         if (isset($data['notnull'])) {
45
-            $instance->setNullable(!((int)$data['notnull']));
45
+            $instance->setNullable(!((int) $data['notnull']));
46 46
         }
47 47
         if (isset($data['Default'])) {
48 48
             $instance->setDefault($data['Default']);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $instance->setLength($data['length']);
58 58
         }
59 59
         if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) {
60
-            $temp = array_map(function ($v) {
60
+            $temp = array_map(function($v) {
61 61
                 return str_replace("''", "'", $v);
62 62
             }, explode("','", substr($instance->getType(), 6, -2)));
63 63
             $instance->setValues($temp);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 $instance->setDefault(null);
87 87
             }
88 88
         }
89
-        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int)$data['CHAR_LENGTH']) {
89
+        if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int) $data['CHAR_LENGTH']) {
90 90
             $instance->setLength($data['CHAR_LENGTH']);
91 91
         }
92 92
         return $instance;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     }
184 184
     public function getLength(): int
185 185
     {
186
-        return (int)$this->length;
186
+        return (int) $this->length;
187 187
     }
188 188
     public function setLength(int $length): static
189 189
     {
Please login to merge, or discard this patch.
src/DBInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,8 +104,8 @@
 block discarded – undo
104 104
     public function delete(Entity $entity): void;
105 105
     public function save(?Entity $entity = null): void;
106 106
 
107
-    public function getMapper(Table|string $table): MapperInterface;
108
-    public function setMapper(Table|string $table, MapperInterface $mapper, ?string $class = null): static;
107
+    public function getMapper(Table | string $table): MapperInterface;
108
+    public function setMapper(Table | string $table, MapperInterface $mapper, ?string $class = null): static;
109 109
     public function tableMapped(
110 110
         string $table,
111 111
         bool $findRelations = false,
Please login to merge, or discard this patch.
src/schema/MapperInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,12 +58,12 @@
 block discarded – undo
58 58
      * @param T $entity
59 59
      * @return bool
60 60
      */
61
-    public function deleted(array|object $entity): bool;
61
+    public function deleted(array | object $entity): bool;
62 62
     /**
63 63
      * @param T $entity
64 64
      * @return bool
65 65
      */
66
-    public function exists(array|object $entity): bool;
66
+    public function exists(array | object $entity): bool;
67 67
     /**
68 68
      * @return array<int,T>
69 69
      */
Please login to merge, or discard this patch.
src/driver/sqlite/Schema.php 1 patch
Spacing   +22 added lines, -22 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;
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
                             ]
54 54
                         )
55 55
                     );
56
-                    $relationsT['main.' . $row['table']][] = $row;
57
-                    $relationsR['main.' . $row['referenced_table']][] = $row;
56
+                    $relationsT['main.'.$row['table']][] = $row;
57
+                    $relationsR['main.'.$row['referenced_table']][] = $row;
58 58
                 }
59 59
             }
60 60
         }
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
          */
65 65
         $columns = Collection::from($this
66 66
             ->query("PRAGMA table_info(".$table.")"))
67
-            ->mapKey(function ($v): string {
67
+            ->mapKey(function($v): string {
68 68
                 return $v['name'];
69 69
             })
70
-            ->map(function ($v) {
70
+            ->map(function($v) {
71 71
                 $v['length'] = null;
72 72
                 if (!isset($v['type'])) {
73 73
                     return $v;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     default:
78 78
                         if (strpos($type, 'char') !== false && strpos($type, '(') !== false) {
79 79
                             // extract length from varchar
80
-                            $v['length'] = (int)explode(')', explode('(', $type)[1])[0];
80
+                            $v['length'] = (int) explode(')', explode('(', $type)[1])[0];
81 81
                             $v['length'] = $v['length'] > 0 ? $v['length'] : null;
82 82
                         }
83 83
                         break;
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
             })
87 87
             ->toArray();
88 88
         if (!count($columns)) {
89
-            throw new DBException('Table not found by name: ' . implode('.', [$schema,$table]));
89
+            throw new DBException('Table not found by name: '.implode('.', [$schema, $table]));
90 90
         }
91 91
         $primary = [];
92 92
         foreach ($columns as $column) {
93
-            if ((int)$column['pk']) {
93
+            if ((int) $column['pk']) {
94 94
                 $primary[] = $column['name'];
95 95
             }
96 96
         }
97
-        $tables[$schema . '.' .$table] = $definition = (new Table($table, $schema))
97
+        $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema))
98 98
             ->addColumns($columns)
99 99
             ->setPrimaryKey($primary)
100 100
             ->setComment('');
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
             // assuming current table is on the "one" end having "many" records in the referencing table
105 105
             // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected)
106 106
             $relations = [];
107
-            foreach ($relationsR[$schema . '.' . $table] ?? [] as $k => $relation) {
108
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['table'];
107
+            foreach ($relationsR[$schema.'.'.$table] ?? [] as $k => $relation) {
108
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['table'];
109 109
                 $relations[$relation['constraint_name']]['keymap'][$relation['to']] = $relation['from'];
110 110
             }
111 111
             foreach ($relations as $data) {
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
                 $usedcol = [];
121 121
                 if (count($columns)) {
122 122
                     foreach (Collection::from($relationsT[$data['table']] ?? [])
123
-                        ->filter(function ($v) use ($columns) {
123
+                        ->filter(function($v) use ($columns) {
124 124
                             return in_array($v['from'], $columns);
125 125
                         }) as $relation
126 126
                     ) {
127
-                        $foreign[$relation['constraint_name']]['table'] = 'main.' .
127
+                        $foreign[$relation['constraint_name']]['table'] = 'main.'.
128 128
                             $relation['referenced_table'];
129 129
                         $foreign[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
130 130
                         $usedcol[] = $relation['from'];
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                         $definition->getName() == $relname ||
144 144
                         $definition->getColumn($relname)
145 145
                     ) {
146
-                        $relname = $orig . '_' . (++ $cntr);
146
+                        $relname = $orig.'_'.(++$cntr);
147 147
                     }
148 148
                     $definition->addRelation(
149 149
                         new TableRelation(
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                         $definition->getName() == $relname ||
168 168
                         $definition->getColumn($relname)
169 169
                     ) {
170
-                        $relname = $orig . '_' . (++ $cntr);
170
+                        $relname = $orig.'_'.(++$cntr);
171 171
                     }
172 172
                     $definition->addRelation(
173 173
                         new TableRelation(
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
             // assuming current table is linked to "one" record in the referenced table
184 184
             // resulting in a "belongsTo" relationship
185 185
             $relations = [];
186
-            foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) {
187
-                $relations[$relation['constraint_name']]['table'] = 'main.' . $relation['referenced_table'];
186
+            foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) {
187
+                $relations[$relation['constraint_name']]['table'] = 'main.'.$relation['referenced_table'];
188 188
                 $relations[$relation['constraint_name']]['keymap'][$relation['from']] = $relation['to'];
189 189
             }
190 190
             foreach ($relations as $name => $data) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $definition->getName() == $relname ||
200 200
                     $definition->getColumn($relname)
201 201
                 ) {
202
-                    $relname = $orig . '_' . (++ $cntr);
202
+                    $relname = $orig.'_'.(++$cntr);
203 203
                 }
204 204
                 $definition->addRelation(
205 205
                     new TableRelation(
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
                 "SELECT tbl_name
221 221
                  FROM sqlite_schema
222 222
                  WHERE (type = ? OR type = ?) AND tbl_name NOT LIKE 'sqlite_%';",
223
-                [ 'table', 'view' ]
223
+                ['table', 'view']
224 224
             ))
225
-            ->mapKey(function ($v) {
225
+            ->mapKey(function($v) {
226 226
                 return strtolower($v['tbl_name']);
227 227
             })
228 228
             ->pluck('tbl_name')
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
             $tables[$k] = $this->table($v, true, array_keys($tables))->toLowerCase();
232 232
         }
233 233
         foreach (array_keys($tables) as $k) {
234
-            $tables[($this->connection['opts']['schema'] ?? 'main') . '.' . $k] = &$tables[$k];
234
+            $tables[($this->connection['opts']['schema'] ?? 'main').'.'.$k] = &$tables[$k];
235 235
         }
236 236
         return $tables;
237 237
     }
Please login to merge, or discard this patch.