Completed
Push — master ( 1679f6...961af6 )
by Ivan
03:12
created
src/DB.php 1 patch
Spacing   +14 added lines, -16 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $connection['pass'] = isset($temp['pass']) && strlen($temp['pass']) ? $temp['pass'] : null;
69 69
         $connection['host'] = isset($temp['host']) && strlen($temp['host']) ? $temp['host'] : null;
70 70
         $connection['name'] = isset($temp['path']) && strlen($temp['path']) ? trim($temp['path'], '/') : null;
71
-        $connection['port'] = isset($temp['port']) && (int)$temp['port'] ? (int)$temp['port'] : null;
71
+        $connection['port'] = isset($temp['port']) && (int) $temp['port'] ? (int) $temp['port'] : null;
72 72
         if (isset($temp['query']) && strlen($temp['query'])) {
73 73
             parse_str($temp['query'], $connection['opts']);
74 74
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         $new = '';
107 107
         $par = array_values($par);
108 108
         if (substr_count($sql, '?') === 2 && !is_array($par[0])) {
109
-            $par = [ $par ];
109
+            $par = [$par];
110 110
         }
111 111
         $parts = explode('??', $sql);
112 112
         $index = 0;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             $index += count($tmp) - 1;
117 117
             if (isset($par[$index])) {
118 118
                 if (!is_array($par[$index])) {
119
-                    $par[$index] = [ $par[$index] ];
119
+                    $par[$index] = [$par[$index]];
120 120
                 }
121 121
                 $params = $par[$index];
122 122
                 array_splice($par, $index, 1, $params);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                 $new .= implode(',', array_fill(0, count($params), '?'));
125 125
             }
126 126
         }
127
-        return [ $new, $par ];
127
+        return [$new, $par];
128 128
     }
129 129
     /**
130 130
      * Run a query (prepare & execute).
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     {
157 157
         $coll = Collection::from($this->query($sql, $par));
158 158
         if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) {
159
-            $coll->map(function ($v) use ($keys) {
159
+            $coll->map(function($v) use ($keys) {
160 160
                 $new = [];
161 161
                 foreach ($v as $k => $vv) {
162 162
                     $new[call_user_func($keys, $k)] = $vv;
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
             });
166 166
         }
167 167
         if ($key !== null) {
168
-            $coll->mapKey(function ($v) use ($key) {
168
+            $coll->mapKey(function($v) use ($key) {
169 169
                 return $v[$key];
170 170
             });
171 171
         }
172 172
         if ($skip) {
173
-            $coll->map(function ($v) use ($key) {
173
+            $coll->map(function($v) use ($key) {
174 174
                 unset($v[$key]);
175 175
                 return $v;
176 176
             });
177 177
         }
178 178
         if ($opti) {
179
-            $coll->map(function ($v) {
179
+            $coll->map(function($v) {
180 180
                 return count($v) === 1 ? current($v) : $v;
181 181
             });
182 182
         }
@@ -262,8 +262,7 @@  discard block
 block discarded – undo
262 262
     public function definition(string $table, bool $detectRelations = true) : Table
263 263
     {
264 264
         return isset($this->tables[$table]) ?
265
-            $this->tables[$table] :
266
-            $this->driver->table($table, $detectRelations);
265
+            $this->tables[$table] : $this->driver->table($table, $detectRelations);
267 266
     }
268 267
     /**
269 268
      * Parse all tables from the database.
@@ -280,12 +279,12 @@  discard block
 block discarded – undo
280 279
      */
281 280
     public function getSchema($asPlainArray = true)
282 281
     {
283
-        return !$asPlainArray ? $this->tables : array_map(function ($table) {
282
+        return !$asPlainArray ? $this->tables : array_map(function($table) {
284 283
             return [
285 284
                 'name' => $table->getName(),
286 285
                 'pkey' => $table->getPrimaryKey(),
287 286
                 'comment' => $table->getComment(),
288
-                'columns' => array_map(function ($column) {
287
+                'columns' => array_map(function($column) {
289 288
                     return [
290 289
                         'name' => $column->getName(),
291 290
                         'type' => $column->getType(),
@@ -296,9 +295,9 @@  discard block
 block discarded – undo
296 295
                         'nullable' => $column->isNullable()
297 296
                     ];
298 297
                 }, $table->getFullColumns()),
299
-                'relations' => array_map(function ($rel) {
298
+                'relations' => array_map(function($rel) {
300 299
                     $relation = clone $rel;
301
-                    $relation = (array)$relation;
300
+                    $relation = (array) $relation;
302 301
                     $relation['table'] = $rel->table->getName();
303 302
                     if ($rel->pivot) {
304 303
                         $relation['pivot'] = $rel->pivot->getName();
@@ -351,8 +350,7 @@  discard block
 block discarded – undo
351 350
     public function table(string $table, bool $mapped = false)
352 351
     {
353 352
         return $mapped ?
354
-            new TableQueryMapped($this, $this->definition($table)) :
355
-            new TableQuery($this, $this->definition($table));
353
+            new TableQueryMapped($this, $this->definition($table)) : new TableQuery($this, $this->definition($table));
356 354
     }
357 355
     public function __call($method, $args)
358 356
     {
Please login to merge, or discard this patch.