@@ -157,8 +157,7 @@ discard block |
||
157 | 157 | if ($this->isSQLite()) { |
158 | 158 | $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll(); |
159 | 159 | $cols = array_column($info, 'name'); |
160 | - } |
|
161 | - else { |
|
160 | + } else { |
|
162 | 161 | $cols = $this->query( |
163 | 162 | "SELECT column_name FROM information_schema.tables WHERE table_name = {$this->quote($name)}" |
164 | 163 | )->fetchAll(self::FETCH_COLUMN); |
@@ -240,11 +239,9 @@ discard block |
||
240 | 239 | public function offsetGet ($class) { |
241 | 240 | if (is_a($class, EntityInterface::class, true)) { |
242 | 241 | return $this->getRecord($class); |
243 | - } |
|
244 | - elseif (interface_exists($class)) { |
|
242 | + } elseif (interface_exists($class)) { |
|
245 | 243 | return $this->getJunction($class); |
246 | - } |
|
247 | - else { |
|
244 | + } else { |
|
248 | 245 | return $this->getTable($class); |
249 | 246 | } |
250 | 247 | } |
@@ -256,11 +253,9 @@ discard block |
||
256 | 253 | public function offsetSet ($class, $access) { |
257 | 254 | if ($access instanceof Record) { |
258 | 255 | $this->setRecord($class, $access); |
259 | - } |
|
260 | - elseif ($access instanceof Junction) { |
|
256 | + } elseif ($access instanceof Junction) { |
|
261 | 257 | $this->setJunction($class, $access); |
262 | - } |
|
263 | - else { |
|
258 | + } else { |
|
264 | 259 | throw new LogicException('Raw table access is immutable.'); |
265 | 260 | } |
266 | 261 | } |
@@ -117,8 +117,7 @@ discard block |
||
117 | 117 | if ($table instanceof Select) { |
118 | 118 | $this->table = $table->toSubquery(); |
119 | 119 | $this->alias = uniqid('_') . "_{$table->alias}"; |
120 | - } |
|
121 | - else { |
|
120 | + } else { |
|
122 | 121 | $this->table = (string)$table; |
123 | 122 | $this->alias = uniqid('_') . "__{$table}"; |
124 | 123 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | public function group (string $column) { |
229 | 228 | if (!strlen($this->_group)) { |
230 | 229 | $this->_group = " GROUP BY {$column}"; |
231 | - } |
|
232 | - else { |
|
230 | + } else { |
|
233 | 231 | $this->_group .= ", {$column}"; |
234 | 232 | } |
235 | 233 | return $this; |
@@ -244,8 +242,7 @@ discard block |
||
244 | 242 | public function having (string $condition) { |
245 | 243 | if (!strlen($this->_having)) { |
246 | 244 | $this->_having = " HAVING {$condition}"; |
247 | - } |
|
248 | - else { |
|
245 | + } else { |
|
249 | 246 | $this->_having .= " AND {$condition}"; |
250 | 247 | } |
251 | 248 | return $this; |
@@ -264,8 +261,7 @@ discard block |
||
264 | 261 | $select->_limit = ''; |
265 | 262 | if ($all) { |
266 | 263 | $this->_import .= " INTERSECT ALL {$select->toSql()}"; |
267 | - } |
|
268 | - else { |
|
264 | + } else { |
|
269 | 265 | $this->_import .= " INTERSECT {$select->toSql()}"; |
270 | 266 | } |
271 | 267 | return $this; |
@@ -315,8 +311,7 @@ discard block |
||
315 | 311 | public function limit (int $limit, int $offset = 0) { |
316 | 312 | if ($limit == 0) { |
317 | 313 | $this->_limit = ''; |
318 | - } |
|
319 | - else { |
|
314 | + } else { |
|
320 | 315 | $this->_limit = " LIMIT {$limit}"; |
321 | 316 | if ($offset > 1) { |
322 | 317 | $this->_limit .= " OFFSET {$offset}"; |
@@ -389,8 +384,7 @@ discard block |
||
389 | 384 | $name = $match['name'] ?? null; |
390 | 385 | if (is_int($alias)) { |
391 | 386 | $alias = $name; |
392 | - } |
|
393 | - elseif ($alias !== $name) { |
|
387 | + } elseif ($alias !== $name) { |
|
394 | 388 | $expr .= " AS {$alias}"; |
395 | 389 | } |
396 | 390 | if (isset($alias)) { |
@@ -450,8 +444,7 @@ discard block |
||
450 | 444 | $select->_limit = ''; |
451 | 445 | if ($all) { |
452 | 446 | $this->_import .= " UNION ALL {$select->toSql()}"; |
453 | - } |
|
454 | - else { |
|
447 | + } else { |
|
455 | 448 | $this->_import .= " UNION {$select->toSql()}"; |
456 | 449 | } |
457 | 450 | return $this; |
@@ -466,8 +459,7 @@ discard block |
||
466 | 459 | public function where (string $condition) { |
467 | 460 | if (!strlen($this->_where)) { |
468 | 461 | $this->_where = " WHERE {$condition}"; |
469 | - } |
|
470 | - else { |
|
462 | + } else { |
|
471 | 463 | $this->_where .= " AND {$condition}"; |
472 | 464 | } |
473 | 465 | return $this; |
@@ -57,8 +57,7 @@ |
||
57 | 57 | public function offsetSet ($attr, $value): void { |
58 | 58 | if (isset($attr)) { |
59 | 59 | $this->attributes[$attr] = $value; |
60 | - } |
|
61 | - else { |
|
60 | + } else { |
|
62 | 61 | $this->attributes[] = $value; |
63 | 62 | } |
64 | 63 | } |
@@ -64,8 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | if ($arg === null or is_bool($arg)) { |
66 | 66 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
67 | - } |
|
68 | - else { |
|
67 | + } else { |
|
69 | 68 | $arg = $this->db->quote($arg); |
70 | 69 | } |
71 | 70 | if ($this->db->isMySQL()) { |
@@ -73,8 +73,7 @@ discard block |
||
73 | 73 | foreach ($rClass->getProperties() as $rProp) { |
74 | 74 | if (preg_match('/@col(umn)?[\s$]/', $rProp->getDocComment())) { |
75 | 75 | $columns[] = $rProp->getName(); |
76 | - } |
|
77 | - elseif (preg_match('/@eav\s+(?<table>\S+)/', $rProp->getDocComment(), $attr)) { |
|
76 | + } elseif (preg_match('/@eav\s+(?<table>\S+)/', $rProp->getDocComment(), $attr)) { |
|
78 | 77 | $eav[$rProp->getName()] = $db->factory(EAV::class, $db, $attr['table']); |
79 | 78 | } |
80 | 79 | } |
@@ -241,8 +240,7 @@ discard block |
||
241 | 240 | public function save (EntityInterface $entity): int { |
242 | 241 | if (!$entity->getId()) { |
243 | 242 | $this->saveInsert($entity); |
244 | - } |
|
245 | - else { |
|
243 | + } else { |
|
246 | 244 | $this->saveUpdate($entity); |
247 | 245 | } |
248 | 246 | $this->saveEav($entity); |