@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $connection['pass'] = isset($temp['pass']) && strlen($temp['pass']) ? $temp['pass'] : null; |
| 78 | 78 | $connection['host'] = isset($temp['host']) && strlen($temp['host']) ? $temp['host'] : null; |
| 79 | 79 | $connection['name'] = isset($temp['path']) && strlen($temp['path']) ? trim($temp['path'], '/') : null; |
| 80 | - $connection['port'] = isset($temp['port']) && (int)$temp['port'] ? (int)$temp['port'] : null; |
|
| 80 | + $connection['port'] = isset($temp['port']) && (int) $temp['port'] ? (int) $temp['port'] : null; |
|
| 81 | 81 | if (isset($temp['query']) && strlen($temp['query'])) { |
| 82 | 82 | parse_str($temp['query'], $connection['opts']); |
| 83 | 83 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $new = ''; |
| 115 | 115 | $par = array_values($par); |
| 116 | 116 | if (substr_count($sql, '?') === 2 && !is_array($par[0])) { |
| 117 | - $par = [ $par ]; |
|
| 117 | + $par = [$par]; |
|
| 118 | 118 | } |
| 119 | 119 | $parts = explode('??', $sql); |
| 120 | 120 | $index = 0; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $index += count($tmp) - 1; |
| 125 | 125 | if (isset($par[$index])) { |
| 126 | 126 | if (!is_array($par[$index])) { |
| 127 | - $par[$index] = [ $par[$index] ]; |
|
| 127 | + $par[$index] = [$par[$index]]; |
|
| 128 | 128 | } |
| 129 | 129 | $params = $par[$index]; |
| 130 | 130 | array_splice($par, $index, 1, $params); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $new .= implode(',', array_fill(0, count($params), '?')); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - return [ $new, $par ]; |
|
| 135 | + return [$new, $par]; |
|
| 136 | 136 | } |
| 137 | 137 | /** |
| 138 | 138 | * Run a query (prepare & execute). |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | $coll = Collection::from($this->query($sql, $par)); |
| 166 | 166 | if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) { |
| 167 | - $coll->map(function ($v) use ($keys) { |
|
| 167 | + $coll->map(function($v) use ($keys) { |
|
| 168 | 168 | $new = []; |
| 169 | 169 | foreach ($v as $k => $vv) { |
| 170 | 170 | $new[call_user_func($keys, $k)] = $vv; |
@@ -173,18 +173,18 @@ discard block |
||
| 173 | 173 | }); |
| 174 | 174 | } |
| 175 | 175 | if ($key !== null) { |
| 176 | - $coll->mapKey(function ($v) use ($key) { |
|
| 176 | + $coll->mapKey(function($v) use ($key) { |
|
| 177 | 177 | return $v[$key]; |
| 178 | 178 | }); |
| 179 | 179 | } |
| 180 | 180 | if ($skip) { |
| 181 | - $coll->map(function ($v) use ($key) { |
|
| 181 | + $coll->map(function($v) use ($key) { |
|
| 182 | 182 | unset($v[$key]); |
| 183 | 183 | return $v; |
| 184 | 184 | }); |
| 185 | 185 | } |
| 186 | 186 | if ($opti) { |
| 187 | - $coll->map(function ($v) { |
|
| 187 | + $coll->map(function($v) { |
|
| 188 | 188 | return count($v) === 1 ? current($v) : $v; |
| 189 | 189 | }); |
| 190 | 190 | } |
@@ -270,8 +270,7 @@ discard block |
||
| 270 | 270 | public function definition(string $table, bool $detectRelations = true) : Table |
| 271 | 271 | { |
| 272 | 272 | return isset($this->tables[$table]) ? |
| 273 | - $this->tables[$table] : |
|
| 274 | - $this->driver->table($table, $detectRelations); |
|
| 273 | + $this->tables[$table] : $this->driver->table($table, $detectRelations); |
|
| 275 | 274 | } |
| 276 | 275 | /** |
| 277 | 276 | * Parse all tables from the database. |
@@ -288,12 +287,12 @@ discard block |
||
| 288 | 287 | */ |
| 289 | 288 | public function getSchema($asPlainArray = true) |
| 290 | 289 | { |
| 291 | - return !$asPlainArray ? $this->tables : array_map(function ($table) { |
|
| 290 | + return !$asPlainArray ? $this->tables : array_map(function($table) { |
|
| 292 | 291 | return [ |
| 293 | 292 | 'name' => $table->getName(), |
| 294 | 293 | 'pkey' => $table->getPrimaryKey(), |
| 295 | 294 | 'comment' => $table->getComment(), |
| 296 | - 'columns' => array_map(function ($column) { |
|
| 295 | + 'columns' => array_map(function($column) { |
|
| 297 | 296 | return [ |
| 298 | 297 | 'name' => $column->getName(), |
| 299 | 298 | 'type' => $column->getType(), |
@@ -304,9 +303,9 @@ discard block |
||
| 304 | 303 | 'nullable' => $column->isNullable() |
| 305 | 304 | ]; |
| 306 | 305 | }, $table->getFullColumns()), |
| 307 | - 'relations' => array_map(function ($rel) { |
|
| 306 | + 'relations' => array_map(function($rel) { |
|
| 308 | 307 | $relation = clone $rel; |
| 309 | - $relation = (array)$relation; |
|
| 308 | + $relation = (array) $relation; |
|
| 310 | 309 | $relation['table'] = $rel->table->getName(); |
| 311 | 310 | if ($rel->pivot) { |
| 312 | 311 | $relation['pivot'] = $rel->pivot->getName(); |
@@ -359,8 +358,7 @@ discard block |
||
| 359 | 358 | public function table($table, bool $mapped = false) |
| 360 | 359 | { |
| 361 | 360 | return $mapped ? |
| 362 | - new TableQueryMapped($this, $this->definition($table)) : |
|
| 363 | - new TableQuery($this, $this->definition($table)); |
|
| 361 | + new TableQueryMapped($this, $this->definition($table)) : new TableQuery($this, $this->definition($table)); |
|
| 364 | 362 | } |
| 365 | 363 | public function __call($method, $args) |
| 366 | 364 | { |