Completed
Push — master ( 835dfc...c628c4 )
by Ivan
02:03
created
src/DB.php 1 patch
Spacing   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
             $connection['name'] = $path;
81 81
         }
82 82
         $connection['type'] = isset($aliases[$connection['type']]) ?
83
-            $aliases[$connection['type']] :
84
-            $connection['type'];
83
+            $aliases[$connection['type']] : $connection['type'];
85 84
         $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver';
86 85
         return new $tmp($connection);
87 86
     }
@@ -110,7 +109,7 @@  discard block
 block discarded – undo
110 109
         $new = '';
111 110
         $par = array_values($par);
112 111
         if (substr_count($sql, '?') === 2 && !is_array($par[0])) {
113
-            $par = [ $par ];
112
+            $par = [$par];
114 113
         }
115 114
         $parts = explode('??', $sql);
116 115
         $index = 0;
@@ -120,7 +119,7 @@  discard block
 block discarded – undo
120 119
             $index += count($tmp) - 1;
121 120
             if (isset($par[$index])) {
122 121
                 if (!is_array($par[$index])) {
123
-                    $par[$index] = [ $par[$index] ];
122
+                    $par[$index] = [$par[$index]];
124 123
                 }
125 124
                 $params = $par[$index];
126 125
                 array_splice($par, $index, 1, $params);
@@ -128,7 +127,7 @@  discard block
 block discarded – undo
128 127
                 $new .= implode(',', array_fill(0, count($params), '?'));
129 128
             }
130 129
         }
131
-        return [ $new, $par ];
130
+        return [$new, $par];
132 131
     }
133 132
     /**
134 133
      * Run a query (prepare & execute).
@@ -160,7 +159,7 @@  discard block
 block discarded – undo
160 159
     {
161 160
         $coll = Collection::from($this->query($sql, $par));
162 161
         if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) {
163
-            $coll->map(function ($v) use ($keys) {
162
+            $coll->map(function($v) use ($keys) {
164 163
                 $new = [];
165 164
                 foreach ($v as $k => $vv) {
166 165
                     $new[call_user_func($keys, $k)] = $vv;
@@ -169,13 +168,13 @@  discard block
 block discarded – undo
169 168
             });
170 169
         }
171 170
         if ($key !== null) {
172
-            $coll->mapKey(function ($v) use ($key) { return $v[$key]; });
171
+            $coll->mapKey(function($v) use ($key) { return $v[$key]; });
173 172
         }
174 173
         if ($skip) {
175
-            $coll->map(function ($v) use ($key) { unset($v[$key]); return $v; });
174
+            $coll->map(function($v) use ($key) { unset($v[$key]); return $v; });
176 175
         }
177 176
         if ($opti) {
178
-            $coll->map(function ($v) { return count($v) === 1 ? current($v) : $v; });
177
+            $coll->map(function($v) { return count($v) === 1 ? current($v) : $v; });
179 178
         }
180 179
         return $coll;
181 180
     }
@@ -259,8 +258,7 @@  discard block
 block discarded – undo
259 258
     public function definition(string $table, bool $detectRelations = true) : Table
260 259
     {
261 260
         return isset($this->tables[$table]) ?
262
-            $this->tables[$table] :
263
-            $this->driver->table($table, $detectRelations);
261
+            $this->tables[$table] : $this->driver->table($table, $detectRelations);
264 262
     }
265 263
     /**
266 264
      * Parse all tables from the database.
@@ -277,12 +275,12 @@  discard block
 block discarded – undo
277 275
      */
278 276
     public function getSchema($asPlainArray = true)
279 277
     {
280
-        return !$asPlainArray ? $this->tables : array_map(function ($table) {
278
+        return !$asPlainArray ? $this->tables : array_map(function($table) {
281 279
             return [
282 280
                 'name' => $table->getName(),
283 281
                 'pkey' => $table->getPrimaryKey(),
284 282
                 'comment' => $table->getComment(),
285
-                'columns' => array_map(function ($column) {
283
+                'columns' => array_map(function($column) {
286 284
                     return [
287 285
                         'name' => $column->getName(),
288 286
                         'type' => $column->getType(),
@@ -293,13 +291,13 @@  discard block
 block discarded – undo
293 291
                         'nullable' => $column->isNullable()
294 292
                     ];
295 293
                 }, $table->getFullColumns()),
296
-                'relations' => array_map(function ($rel) {
294
+                'relations' => array_map(function($rel) {
297 295
                     $relation = clone $rel;
298 296
                     $relation->table = $relation->table->getName();
299 297
                     if ($relation->pivot) {
300 298
                         $relation->pivot = $relation->pivot->getName();
301 299
                     }
302
-                    return (array)$relation;
300
+                    return (array) $relation;
303 301
                 }, $table->getRelations())
304 302
             ];
305 303
         }, $this->tables);
@@ -347,8 +345,7 @@  discard block
 block discarded – undo
347 345
     public function table($table, bool $mapped = false)
348 346
     {
349 347
         return $mapped ?
350
-            new TableQueryMapped($this, $this->definition($table)) :
351
-            new TableQuery($this, $this->definition($table));
348
+            new TableQueryMapped($this, $this->definition($table)) : new TableQuery($this, $this->definition($table));
352 349
     }
353 350
     public function __call($method, $args)
354 351
     {
Please login to merge, or discard this patch.