@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $password |
60 | 60 | * @param array $options |
61 | 61 | */ |
62 | - public function __construct ($dsn, $username = null, $password = null, $options = null) { |
|
62 | + public function __construct($dsn, $username = null, $password = null, $options = null) { |
|
63 | 63 | parent::__construct($dsn, $username, $password, $options); |
64 | 64 | $this->driver = $this->getAttribute(self::ATTR_DRIVER_NAME); |
65 | 65 | $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - final public function __toString () { |
|
84 | + final public function __toString() { |
|
85 | 85 | return $this->driver; |
86 | 86 | } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param string $sql |
92 | 92 | * @return int |
93 | 93 | */ |
94 | - public function exec ($sql): int { |
|
94 | + public function exec($sql): int { |
|
95 | 95 | $this->logger->__invoke($sql); |
96 | 96 | return parent::exec($sql); |
97 | 97 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | * @param mixed ...$args |
106 | 106 | * @return mixed |
107 | 107 | */ |
108 | - public function factory (string $class, ...$args) { |
|
108 | + public function factory(string $class, ...$args) { |
|
109 | 109 | return new $class(...$args); |
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
113 | 113 | * @return string |
114 | 114 | */ |
115 | - final public function getDriver (): string { |
|
115 | + final public function getDriver(): string { |
|
116 | 116 | return $this->driver; |
117 | 117 | } |
118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param string $interface |
123 | 123 | * @return Junction |
124 | 124 | */ |
125 | - public function getJunction ($interface) { |
|
125 | + public function getJunction($interface) { |
|
126 | 126 | return $this->junctions[$interface] |
127 | 127 | ?? $this->junctions[$interface] = Junction::fromInterface($this, $interface); |
128 | 128 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * @return Closure |
132 | 132 | */ |
133 | - public function getLogger () { |
|
133 | + public function getLogger() { |
|
134 | 134 | return $this->logger; |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string|EntityInterface $class |
141 | 141 | * @return Record |
142 | 142 | */ |
143 | - public function getRecord ($class) { |
|
143 | + public function getRecord($class) { |
|
144 | 144 | if (is_object($class)) { |
145 | 145 | $class = get_class($class); |
146 | 146 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param string $name |
153 | 153 | * @return null|Table |
154 | 154 | */ |
155 | - public function getTable (string $name) { |
|
155 | + public function getTable(string $name) { |
|
156 | 156 | if (!isset($this->tables[$name])) { |
157 | 157 | if ($this->isSQLite()) { |
158 | 158 | $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll(); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | "SELECT column_name FROM information_schema.tables WHERE table_name = {$this->quote($name)}" |
164 | 164 | )->fetchAll(self::FETCH_COLUMN); |
165 | 165 | } |
166 | - if (!$cols){ |
|
166 | + if (!$cols) { |
|
167 | 167 | return null; |
168 | 168 | } |
169 | 169 | $this->tables[$name] = $this->factory(Table::class, $this, $name, $cols); |
@@ -174,21 +174,21 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @return bool |
176 | 176 | */ |
177 | - final public function isMySQL (): bool { |
|
177 | + final public function isMySQL(): bool { |
|
178 | 178 | return $this->driver === 'mysql'; |
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | 182 | * @return bool |
183 | 183 | */ |
184 | - final public function isPostgreSQL (): bool { |
|
184 | + final public function isPostgreSQL(): bool { |
|
185 | 185 | return $this->driver === 'pgsql'; |
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | 189 | * @return bool |
190 | 190 | */ |
191 | - final public function isSQLite (): bool { |
|
191 | + final public function isSQLite(): bool { |
|
192 | 192 | return $this->driver === 'sqlite'; |
193 | 193 | } |
194 | 194 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param mixed $b |
210 | 210 | * @return Predicate |
211 | 211 | */ |
212 | - public function match ($a, $b) { |
|
212 | + public function match($a, $b) { |
|
213 | 213 | if ($b instanceof Closure) { |
214 | 214 | return $b->__invoke($a, $this); |
215 | 215 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param string $class Class or interface name. |
230 | 230 | * @return bool |
231 | 231 | */ |
232 | - public function offsetExists ($class): bool { |
|
232 | + public function offsetExists($class): bool { |
|
233 | 233 | return (bool)$this->offsetGet($class); |
234 | 234 | } |
235 | 235 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param string $class Class or interface name. |
238 | 238 | * @return null|Table|Record|Junction |
239 | 239 | */ |
240 | - public function offsetGet ($class) { |
|
240 | + public function offsetGet($class) { |
|
241 | 241 | if (is_a($class, EntityInterface::class, true)) { |
242 | 242 | return $this->getRecord($class); |
243 | 243 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param mixed $class Class or interface name. |
254 | 254 | * @param Table|Record|Junction $access |
255 | 255 | */ |
256 | - public function offsetSet ($class, $access) { |
|
256 | + public function offsetSet($class, $access) { |
|
257 | 257 | if ($access instanceof Record) { |
258 | 258 | $this->setRecord($class, $access); |
259 | 259 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | /** |
269 | 269 | * @param string $class Class or interface name. |
270 | 270 | */ |
271 | - public function offsetUnset ($class) { |
|
271 | + public function offsetUnset($class) { |
|
272 | 272 | unset($this->records[$class]); |
273 | 273 | unset($this->junctions[$class]); |
274 | 274 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param array $options |
281 | 281 | * @return Statement |
282 | 282 | */ |
283 | - public function prepare ($sql, $options = []) { |
|
283 | + public function prepare($sql, $options = []) { |
|
284 | 284 | $this->logger->__invoke($sql); |
285 | 285 | /** @var Statement $statement */ |
286 | 286 | $statement = parent::prepare($sql, $options); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param array $ctorargs Optional. |
297 | 297 | * @return Statement |
298 | 298 | */ |
299 | - public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
299 | + public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
300 | 300 | $this->logger->__invoke($sql); |
301 | 301 | /** @var Statement $statement */ |
302 | 302 | $statement = parent::query(...func_get_args()); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param int $type Ignored. |
315 | 315 | * @return string|ExpressionInterface |
316 | 316 | */ |
317 | - public function quote ($value, $type = self::PARAM_STR) { |
|
317 | + public function quote($value, $type = self::PARAM_STR) { |
|
318 | 318 | if ($value instanceof ExpressionInterface) { |
319 | 319 | return $value; |
320 | 320 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param array $values |
335 | 335 | * @return string[] |
336 | 336 | */ |
337 | - public function quoteArray (array $values) { |
|
337 | + public function quoteArray(array $values) { |
|
338 | 338 | return array_map([$this, 'quote'], $values); |
339 | 339 | } |
340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param array $values |
345 | 345 | * @return string |
346 | 346 | */ |
347 | - public function quoteList (array $values): string { |
|
347 | + public function quoteList(array $values): string { |
|
348 | 348 | return implode(',', $this->quoteArray($values)); |
349 | 349 | } |
350 | 350 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param EntityInterface $entity |
355 | 355 | * @return int ID |
356 | 356 | */ |
357 | - public function save (EntityInterface $entity): int { |
|
357 | + public function save(EntityInterface $entity): int { |
|
358 | 358 | return $this->getRecord($entity)->save($entity); |
359 | 359 | } |
360 | 360 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param Junction $junction |
364 | 364 | * @return $this |
365 | 365 | */ |
366 | - public function setJunction (string $interface, Junction $junction) { |
|
366 | + public function setJunction(string $interface, Junction $junction) { |
|
367 | 367 | $this->junctions[$interface] = $junction; |
368 | 368 | return $this; |
369 | 369 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @param Closure $logger |
373 | 373 | * @return $this |
374 | 374 | */ |
375 | - public function setLogger (Closure $logger) { |
|
375 | + public function setLogger(Closure $logger) { |
|
376 | 376 | $this->logger = $logger; |
377 | 377 | return $this; |
378 | 378 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @param Record $record |
383 | 383 | * @return $this |
384 | 384 | */ |
385 | - public function setRecord (string $class, Record $record) { |
|
385 | + public function setRecord(string $class, Record $record) { |
|
386 | 386 | $this->records[$class] = $record; |
387 | 387 | return $this; |
388 | 388 | } |
@@ -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 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param string|Select $table |
113 | 113 | * @param string[] $columns |
114 | 114 | */ |
115 | - public function __construct (DB $db, $table, array $columns) { |
|
115 | + public function __construct(DB $db, $table, array $columns) { |
|
116 | 116 | parent::__construct($db); |
117 | 117 | if ($table instanceof Select) { |
118 | 118 | $this->table = $table->toSubquery(); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param array $args |
133 | 133 | * @return Statement |
134 | 134 | */ |
135 | - public function __invoke (array $args = []) { |
|
135 | + public function __invoke(array $args = []) { |
|
136 | 136 | return $this->execute($args); |
137 | 137 | } |
138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - final public function __toString () { |
|
144 | + final public function __toString() { |
|
145 | 145 | return $this->alias; |
146 | 146 | } |
147 | 147 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param array $args Execution arguments. |
152 | 152 | * @return int |
153 | 153 | */ |
154 | - public function count (array $args = []): int { |
|
154 | + public function count(array $args = []): int { |
|
155 | 155 | $clone = clone $this; |
156 | 156 | $clone->_columns = 'COUNT(*)'; |
157 | 157 | $clone->_order = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param array $args |
165 | 165 | * @return Statement |
166 | 166 | */ |
167 | - public function execute (array $args = []) { |
|
167 | + public function execute(array $args = []) { |
|
168 | 168 | if (empty($args)) { |
169 | 169 | return $this->db->query($this->toSql()); |
170 | 170 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $args Execution arguments. |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - public function getAll (array $args = []): array { |
|
182 | + public function getAll(array $args = []): array { |
|
183 | 183 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
184 | 184 | } |
185 | 185 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param array $args Execution arguments. |
193 | 193 | * @return Generator |
194 | 194 | */ |
195 | - public function getEach (array $args = []) { |
|
195 | + public function getEach(array $args = []) { |
|
196 | 196 | yield from $this->fetcher->__invoke($this->execute($args)); |
197 | 197 | } |
198 | 198 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param array $args |
205 | 205 | * @return mixed |
206 | 206 | */ |
207 | - public function getFirst (array $args = []) { |
|
207 | + public function getFirst(array $args = []) { |
|
208 | 208 | return $this->getEach($args)->current(); |
209 | 209 | } |
210 | 210 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return Generator |
217 | 217 | */ |
218 | - public function getIterator () { |
|
218 | + public function getIterator() { |
|
219 | 219 | yield from $this->getEach(); |
220 | 220 | } |
221 | 221 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $column |
226 | 226 | * @return $this |
227 | 227 | */ |
228 | - public function group (string $column) { |
|
228 | + public function group(string $column) { |
|
229 | 229 | if (!strlen($this->_group)) { |
230 | 230 | $this->_group = " GROUP BY {$column}"; |
231 | 231 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param string $condition |
242 | 242 | * @return $this |
243 | 243 | */ |
244 | - public function having (string $condition) { |
|
244 | + public function having(string $condition) { |
|
245 | 245 | if (!strlen($this->_having)) { |
246 | 246 | $this->_having = " HAVING {$condition}"; |
247 | 247 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param bool $all |
259 | 259 | * @return $this |
260 | 260 | */ |
261 | - public function intersect (Select $select, $all = false) { |
|
261 | + public function intersect(Select $select, $all = false) { |
|
262 | 262 | $select = clone $select; |
263 | 263 | $select->_order = ''; |
264 | 264 | $select->_limit = ''; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return Predicate |
278 | 278 | */ |
279 | - public function isEmpty () { |
|
279 | + public function isEmpty() { |
|
280 | 280 | return $this->db->factory(Predicate::class, "NOT EXISTS ({$this->toSql()})"); |
281 | 281 | } |
282 | 282 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return Predicate |
287 | 287 | */ |
288 | - public function isNotEmpty () { |
|
288 | + public function isNotEmpty() { |
|
289 | 289 | return $this->db->factory(Predicate::class, "EXISTS ({$this->toSql()})"); |
290 | 290 | } |
291 | 291 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param string $type |
298 | 298 | * @return $this |
299 | 299 | */ |
300 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
300 | + public function join($table, string $condition, string $type = 'INNER') { |
|
301 | 301 | if ($table instanceof Select) { |
302 | 302 | $table = $table->toSubquery(); |
303 | 303 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param int $offset |
313 | 313 | * @return $this |
314 | 314 | */ |
315 | - public function limit (int $limit, int $offset = 0) { |
|
315 | + public function limit(int $limit, int $offset = 0) { |
|
316 | 316 | if ($limit == 0) { |
317 | 317 | $this->_limit = ''; |
318 | 318 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param int|string $ref Ordinal or reference name. |
332 | 332 | * @return null|Column |
333 | 333 | */ |
334 | - public function offsetGet ($ref) { |
|
334 | + public function offsetGet($ref) { |
|
335 | 335 | if (is_int($ref)) { |
336 | 336 | return current(array_slice($this->refs, $ref, 1)) ?: null; |
337 | 337 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param string $order |
345 | 345 | * @return $this |
346 | 346 | */ |
347 | - public function order (string $order) { |
|
347 | + public function order(string $order) { |
|
348 | 348 | if (strlen($order)) { |
349 | 349 | $order = " ORDER BY {$order}"; |
350 | 350 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | /** |
356 | 356 | * @return Statement |
357 | 357 | */ |
358 | - public function prepare () { |
|
358 | + public function prepare() { |
|
359 | 359 | return $this->db->prepare($this->toSql()); |
360 | 360 | } |
361 | 361 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param string $alias |
364 | 364 | * @return $this |
365 | 365 | */ |
366 | - public function setAlias (string $alias) { |
|
366 | + public function setAlias(string $alias) { |
|
367 | 367 | $this->alias = $alias; |
368 | 368 | foreach ($this->refs as $k => $column) { |
369 | 369 | $this->refs[$k] = $column->setQualifier($alias); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @param string[] $expressions Keyed by alias if applicable. |
382 | 382 | * @return $this |
383 | 383 | */ |
384 | - public function setColumns (array $expressions) { |
|
384 | + public function setColumns(array $expressions) { |
|
385 | 385 | $this->refs = []; |
386 | 386 | $_columns = []; |
387 | 387 | foreach ($expressions as $alias => $expr) { |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @param Closure $fetcher |
407 | 407 | * @return $this |
408 | 408 | */ |
409 | - public function setFetcher (Closure $fetcher) { |
|
409 | + public function setFetcher(Closure $fetcher) { |
|
410 | 410 | $this->fetcher = $fetcher; |
411 | 411 | return $this; |
412 | 412 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function toSql (): string { |
|
419 | + public function toSql(): string { |
|
420 | 420 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
421 | 421 | $sql .= $this->_join; |
422 | 422 | $sql .= $this->_where; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return string |
435 | 435 | */ |
436 | - public function toSubquery (): string { |
|
436 | + public function toSubquery(): string { |
|
437 | 437 | return "({$this->toSql()}) AS {$this->alias}"; |
438 | 438 | } |
439 | 439 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @param bool $all |
445 | 445 | * @return $this |
446 | 446 | */ |
447 | - public function union (Select $select, $all = false) { |
|
447 | + public function union(Select $select, $all = false) { |
|
448 | 448 | $select = clone $select; |
449 | 449 | $select->_order = ''; |
450 | 450 | $select->_limit = ''; |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param string $condition |
464 | 464 | * @return $this |
465 | 465 | */ |
466 | - public function where (string $condition) { |
|
466 | + public function where(string $condition) { |
|
467 | 467 | if (!strlen($this->_where)) { |
468 | 468 | $this->_where = " WHERE {$condition}"; |
469 | 469 | } |
@@ -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; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function getAttributes (): array { |
|
33 | + public function getAttributes(): array { |
|
34 | 34 | return $this->attributes ?? []; |
35 | 35 | } |
36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param mixed $attr |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | - public function offsetExists ($attr): bool { |
|
41 | + public function offsetExists($attr): bool { |
|
42 | 42 | return isset($this->attributes) and array_key_exists($attr, $this->attributes); |
43 | 43 | } |
44 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param mixed $attr |
47 | 47 | * @return null|mixed |
48 | 48 | */ |
49 | - public function offsetGet ($attr) { |
|
49 | + public function offsetGet($attr) { |
|
50 | 50 | return $this->attributes[$attr] ?? null; |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param mixed $attr |
55 | 55 | * @param mixed $value |
56 | 56 | */ |
57 | - public function offsetSet ($attr, $value): void { |
|
57 | + public function offsetSet($attr, $value): void { |
|
58 | 58 | if (isset($attr)) { |
59 | 59 | $this->attributes[$attr] = $value; |
60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @param mixed $attr |
68 | 68 | */ |
69 | - public function offsetUnset ($attr): void { |
|
69 | + public function offsetUnset($attr): void { |
|
70 | 70 | unset($this->attributes[$attr]); |
71 | 71 | } |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $attributes |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function setAttributes (array $attributes) { |
|
77 | + public function setAttributes(array $attributes) { |
|
78 | 78 | $this->attributes = $attributes; |
79 | 79 | return $this; |
80 | 80 | } |
@@ -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 | } |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - abstract public function __toString (); |
|
19 | + abstract public function __toString(); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param int|string $column |
23 | 23 | * @return null|Column |
24 | 24 | */ |
25 | - abstract public function offsetGet ($column); |
|
25 | + abstract public function offsetGet($column); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var DB |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param DB $db |
34 | 34 | */ |
35 | - public function __construct (DB $db) { |
|
35 | + public function __construct(DB $db) { |
|
36 | 36 | $this->db = $db; |
37 | 37 | } |
38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param int|string $column |
41 | 41 | * @return bool |
42 | 42 | */ |
43 | - public function offsetExists ($column): bool { |
|
43 | + public function offsetExists($column): bool { |
|
44 | 44 | return $this->offsetGet($column) !== null; |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param void $value |
52 | 52 | * @throws Exception |
53 | 53 | */ |
54 | - final public function offsetSet ($offset, $value): void { |
|
54 | + final public function offsetSet($offset, $value): void { |
|
55 | 55 | throw new Exception('Tables are immutable.'); |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param void $name |
62 | 62 | * @throws Exception |
63 | 63 | */ |
64 | - final public function offsetUnset ($name): void { |
|
64 | + final public function offsetUnset($name): void { |
|
65 | 65 | $this->offsetSet($name, null); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param array $values |
29 | 29 | * @return Value |
30 | 30 | */ |
31 | - public function coalesce (array $values) { |
|
31 | + public function coalesce(array $values) { |
|
32 | 32 | array_unshift($values, $this); |
33 | 33 | $values = $this->db->quoteList($values); |
34 | 34 | return $this->db->factory(Value::class, $this->db, "COALESCE({$values})"); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param array $values `[when => then]` |
41 | 41 | * @return Choice |
42 | 42 | */ |
43 | - public function getChoice (array $values) { |
|
43 | + public function getChoice(array $values) { |
|
44 | 44 | return $this->db->factory(Choice::class, $this->db, "{$this}", $values); |
45 | 45 | } |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param null|bool|number|string|Select $arg |
54 | 54 | * @return Predicate |
55 | 55 | */ |
56 | - public function is ($arg): Predicate { |
|
56 | + public function is($arg): Predicate { |
|
57 | 57 | if ($arg instanceof Select) { |
58 | 58 | if ($this->db->isSQLite()) { |
59 | 59 | /** @var Select $sub */ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param number $max |
82 | 82 | * @return Predicate |
83 | 83 | */ |
84 | - public function isBetween ($min, $max) { |
|
84 | + public function isBetween($min, $max) { |
|
85 | 85 | $min = $this->db->quote($min); |
86 | 86 | $max = $this->db->quote($max); |
87 | 87 | return $this->db->factory(Predicate::class, "{$this} BETWEEN {$min} AND {$max}"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param bool|number|string|array|Select $arg |
94 | 94 | * @return Predicate |
95 | 95 | */ |
96 | - public function isEqual ($arg) { |
|
96 | + public function isEqual($arg) { |
|
97 | 97 | return $this->db->match($this, $arg); |
98 | 98 | } |
99 | 99 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param string $multi `ALL|ANY` |
110 | 110 | * @return Predicate |
111 | 111 | */ |
112 | - public function isGreater ($arg, string $multi = 'ALL') { |
|
112 | + public function isGreater($arg, string $multi = 'ALL') { |
|
113 | 113 | if ($arg instanceof Select) { |
114 | 114 | switch ($this->db) { |
115 | 115 | case 'sqlite': |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $multi `ALL|ANY` |
141 | 141 | * @return Predicate |
142 | 142 | */ |
143 | - public function isGreaterOrEqual ($arg, string $multi = 'ALL') { |
|
143 | + public function isGreaterOrEqual($arg, string $multi = 'ALL') { |
|
144 | 144 | if ($arg instanceof Select) { |
145 | 145 | switch ($this->db) { |
146 | 146 | case 'sqlite': |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $multi `ALL|ANY` |
172 | 172 | * @return Predicate |
173 | 173 | */ |
174 | - public function isLess ($arg, string $multi = 'ALL') { |
|
174 | + public function isLess($arg, string $multi = 'ALL') { |
|
175 | 175 | if ($arg instanceof Select) { |
176 | 176 | switch ($this->db) { |
177 | 177 | case 'sqlite': |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $multi `ALL|ANY` |
203 | 203 | * @return Predicate |
204 | 204 | */ |
205 | - public function isLessOrEqual ($arg, string $multi = 'ALL') { |
|
205 | + public function isLessOrEqual($arg, string $multi = 'ALL') { |
|
206 | 206 | if ($arg instanceof Select) { |
207 | 207 | switch ($this->db) { |
208 | 208 | case 'sqlite': |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param string $pattern |
228 | 228 | * @return Predicate |
229 | 229 | */ |
230 | - public function isLike (string $pattern) { |
|
230 | + public function isLike(string $pattern) { |
|
231 | 231 | $pattern = $this->db->quote($pattern); |
232 | 232 | return $this->db->factory(Predicate::class, "{$this} LIKE {$pattern}"); |
233 | 233 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param null|bool|number|string|Select $arg |
239 | 239 | * @return Predicate |
240 | 240 | */ |
241 | - public function isNot ($arg) { |
|
241 | + public function isNot($arg) { |
|
242 | 242 | return $this->is($arg)->invert(); |
243 | 243 | } |
244 | 244 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param number $max |
250 | 250 | * @return Predicate |
251 | 251 | */ |
252 | - public function isNotBetween ($min, $max) { |
|
252 | + public function isNotBetween($min, $max) { |
|
253 | 253 | $min = $this->db->quote($min); |
254 | 254 | $max = $this->db->quote($max); |
255 | 255 | return $this->db->factory(Predicate::class, "{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param bool|number|string|array|Select $arg |
262 | 262 | * @return Predicate |
263 | 263 | */ |
264 | - public function isNotEqual ($arg) { |
|
264 | + public function isNotEqual($arg) { |
|
265 | 265 | if ($arg instanceof Select) { |
266 | 266 | return $this->db->factory(Predicate::class, "{$this} NOT IN ({$arg->toSql()})"); |
267 | 267 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param string $pattern |
278 | 278 | * @return Predicate |
279 | 279 | */ |
280 | - public function isNotLike (string $pattern) { |
|
280 | + public function isNotLike(string $pattern) { |
|
281 | 281 | $pattern = $this->db->quote($pattern); |
282 | 282 | return $this->db->factory(Predicate::class, "{$this} NOT LIKE {$pattern}"); |
283 | 283 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param string $pattern |
289 | 289 | * @return Predicate |
290 | 290 | */ |
291 | - public function isNotRegExp (string $pattern) { |
|
291 | + public function isNotRegExp(string $pattern) { |
|
292 | 292 | $pattern = $this->db->quote($pattern); |
293 | 293 | return $this->db->factory(Predicate::class, "{$this} NOT REGEXP {$pattern}"); |
294 | 294 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param string $pattern |
300 | 300 | * @return Predicate |
301 | 301 | */ |
302 | - public function isRegExp (string $pattern) { |
|
302 | + public function isRegExp(string $pattern) { |
|
303 | 303 | $pattern = $this->db->quote($pattern); |
304 | 304 | return $this->db->factory(Predicate::class, "{$this} REGEXP {$pattern}"); |
305 | 305 | } |
@@ -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()) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param string|EntityInterface $class |
65 | 65 | * @return Record |
66 | 66 | */ |
67 | - public static function fromClass (DB $db, $class) { |
|
67 | + public static function fromClass(DB $db, $class) { |
|
68 | 68 | return (function() use ($db, $class) { |
69 | 69 | $rClass = new ReflectionClass($class); |
70 | 70 | $columns = []; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string[] $columns Property names. |
94 | 94 | * @param EAV[] $eav Keyed by property name. |
95 | 95 | */ |
96 | - public function __construct (DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
96 | + public function __construct(DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
97 | 97 | parent::__construct($db, $table, $columns); |
98 | 98 | $this->proto = $proto; |
99 | 99 | (function() use ($proto, $columns, $eav) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param array[] $eavMatch `[eav property => attribute => mixed]` |
131 | 131 | * @return Select |
132 | 132 | */ |
133 | - public function find (array $match, array $eavMatch = []) { |
|
133 | + public function find(array $match, array $eavMatch = []) { |
|
134 | 134 | $select = $this->select(); |
135 | 135 | foreach ($match as $a => $b) { |
136 | 136 | $select->where($this->db->match($this[$a] ?? $a, $b)); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param Statement $statement |
149 | 149 | * @return EntityInterface[] Keyed by ID |
150 | 150 | */ |
151 | - public function getAll (Statement $statement): array { |
|
151 | + public function getAll(Statement $statement): array { |
|
152 | 152 | return iterator_to_array($this->getEach($statement)); |
153 | 153 | } |
154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param Statement $statement |
160 | 160 | * @return Generator|EntityInterface[] Keyed by ID |
161 | 161 | */ |
162 | - public function getEach (Statement $statement) { |
|
162 | + public function getEach(Statement $statement) { |
|
163 | 163 | do { |
164 | 164 | $entities = []; |
165 | 165 | for ($i = 0; $i < 256 and false !== $row = $statement->fetch(); $i++) { |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | * @param string $property |
177 | 177 | * @return EAV |
178 | 178 | */ |
179 | - final public function getEav (string $property) { |
|
179 | + final public function getEav(string $property) { |
|
180 | 180 | return $this->eav[$property]; |
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | 184 | * @return EntityInterface |
185 | 185 | */ |
186 | - public function getProto () { |
|
186 | + public function getProto() { |
|
187 | 187 | return $this->proto; |
188 | 188 | } |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param EntityInterface $entity |
192 | 192 | * @return array |
193 | 193 | */ |
194 | - protected function getValues (EntityInterface $entity): array { |
|
194 | + protected function getValues(EntityInterface $entity): array { |
|
195 | 195 | $values = []; |
196 | 196 | foreach (array_keys($this->columns) as $name) { |
197 | 197 | $values[$name] = $this->properties[$name]->getValue($entity); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param int $id |
206 | 206 | * @return null|EntityInterface |
207 | 207 | */ |
208 | - public function load (int $id) { |
|
208 | + public function load(int $id) { |
|
209 | 209 | $load = $this->cache(__FUNCTION__, function() { |
210 | 210 | return $this->select(array_keys($this->columns))->where('id = ?')->prepare(); |
211 | 211 | }); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @param EntityInterface[] $entities |
225 | 225 | */ |
226 | - protected function loadEav (array $entities): void { |
|
226 | + protected function loadEav(array $entities): void { |
|
227 | 227 | $ids = array_keys($entities); |
228 | 228 | foreach ($this->eav as $name => $eav) { |
229 | 229 | foreach ($eav->loadAll($ids) as $id => $values) { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param EntityInterface $entity |
239 | 239 | * @return int ID |
240 | 240 | */ |
241 | - public function save (EntityInterface $entity): int { |
|
241 | + public function save(EntityInterface $entity): int { |
|
242 | 242 | if (!$entity->getId()) { |
243 | 243 | $this->saveInsert($entity); |
244 | 244 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * @param EntityInterface $entity |
254 | 254 | */ |
255 | - protected function saveEav (EntityInterface $entity): void { |
|
255 | + protected function saveEav(EntityInterface $entity): void { |
|
256 | 256 | $id = $entity->getId(); |
257 | 257 | foreach ($this->eav as $name => $eav) { |
258 | 258 | // may be null to skip |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @param EntityInterface $entity |
270 | 270 | */ |
271 | - protected function saveInsert (EntityInterface $entity): void { |
|
271 | + protected function saveInsert(EntityInterface $entity): void { |
|
272 | 272 | $insert = $this->cache(__FUNCTION__, function() { |
273 | 273 | $slots = SQL::slots(array_keys($this->columns)); |
274 | 274 | unset($slots['id']); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param EntityInterface $entity |
288 | 288 | */ |
289 | - protected function saveUpdate (EntityInterface $entity): void { |
|
289 | + protected function saveUpdate(EntityInterface $entity): void { |
|
290 | 290 | $this->cache(__FUNCTION__, function() { |
291 | 291 | $slots = SQL::slotsEqual(array_keys($this->columns)); |
292 | 292 | unset($slots['id']); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param array $columns Defaults to all columns. |
302 | 302 | * @return Select |
303 | 303 | */ |
304 | - public function select (array $columns = []) { |
|
304 | + public function select(array $columns = []) { |
|
305 | 305 | $select = parent::select($columns); |
306 | 306 | if (empty($columns)) { |
307 | 307 | $select->setFetcher(function(Statement $statement) { |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param EntityInterface $proto |
316 | 316 | * @return $this |
317 | 317 | */ |
318 | - public function setProto (EntityInterface $proto) { |
|
318 | + public function setProto(EntityInterface $proto) { |
|
319 | 319 | $this->proto = $proto; |
320 | 320 | return $this; |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param EntityInterface $entity |
325 | 325 | * @param array $values |
326 | 326 | */ |
327 | - protected function setValues (EntityInterface $entity, array $values): void { |
|
327 | + protected function setValues(EntityInterface $entity, array $values): void { |
|
328 | 328 | foreach ($values as $name => $value) { |
329 | 329 | settype($value, $this->types[$name]); |
330 | 330 | $this->properties[$name]->setValue($entity, $value); |
@@ -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); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string $name |
40 | 40 | * @param string[] $columns |
41 | 41 | */ |
42 | - public function __construct (DB $db, $name, array $columns) { |
|
42 | + public function __construct(DB $db, $name, array $columns) { |
|
43 | 43 | parent::__construct($db); |
44 | 44 | $this->name = $name; |
45 | 45 | foreach ($columns as $column) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - final public function __toString () { |
|
55 | + final public function __toString() { |
|
56 | 56 | return $this->name; |
57 | 57 | } |
58 | 58 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param array $values |
63 | 63 | * @return int Rows affected. |
64 | 64 | */ |
65 | - public function apply (array $values): int { |
|
65 | + public function apply(array $values): int { |
|
66 | 66 | $columns = implode(',', array_keys($values)); |
67 | 67 | $values = $this->db->quoteList($values); |
68 | 68 | switch ($this->db) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param Closure $prepare `():Statement` |
85 | 85 | * @return Statement |
86 | 86 | */ |
87 | - protected function cache (string $key, Closure $prepare) { |
|
87 | + protected function cache(string $key, Closure $prepare) { |
|
88 | 88 | return $this->_cache[$key] ?? $this->_cache[$key] = $prepare->__invoke(); |
89 | 89 | } |
90 | 90 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param array $match `[a => b]` |
93 | 93 | * @return int |
94 | 94 | */ |
95 | - public function count (array $match = []) { |
|
95 | + public function count(array $match = []) { |
|
96 | 96 | $select = $this->select(['COUNT(*)']); |
97 | 97 | foreach ($match as $a => $b) { |
98 | 98 | $select->where($this->db->match($this[$a] ?? $a, $b)); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param array $match |
109 | 109 | * @return int Rows affected. |
110 | 110 | */ |
111 | - public function delete (array $match): int { |
|
111 | + public function delete(array $match): int { |
|
112 | 112 | foreach ($match as $a => $b) { |
113 | 113 | $match[$a] = $this->db->match($this[$a] ?? $a, $b); |
114 | 114 | } |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @return Column[] |
121 | 121 | */ |
122 | - final public function getColumns (): array { |
|
122 | + final public function getColumns(): array { |
|
123 | 123 | return $this->columns; |
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - final public function getName (): string { |
|
129 | + final public function getName(): string { |
|
130 | 130 | return $this->name; |
131 | 131 | } |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param array $values |
137 | 137 | * @return Statement |
138 | 138 | */ |
139 | - public function insert (array $values) { |
|
139 | + public function insert(array $values) { |
|
140 | 140 | $columns = implode(',', array_keys($values)); |
141 | 141 | $values = $this->db->quoteList($values); |
142 | 142 | return $this->db->query("INSERT INTO {$this} ($columns) VALUES ($values)"); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param int|string $column |
147 | 147 | * @return Column |
148 | 148 | */ |
149 | - public function offsetGet ($column) { |
|
149 | + public function offsetGet($column) { |
|
150 | 150 | if (is_int($column)) { |
151 | 151 | return current(array_slice($this->columns, $column, 1)) ?: null; |
152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string[] $columns Defaults to all columns. |
160 | 160 | * @return Select |
161 | 161 | */ |
162 | - public function select (array $columns = []) { |
|
162 | + public function select(array $columns = []) { |
|
163 | 163 | if (empty($columns)) { |
164 | 164 | $columns = $this->columns; |
165 | 165 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param string $name |
173 | 173 | * @return Table |
174 | 174 | */ |
175 | - public function setName (string $name) { |
|
175 | + public function setName(string $name) { |
|
176 | 176 | $clone = clone $this; |
177 | 177 | $clone->name = $name; |
178 | 178 | foreach ($this->columns as $name => $column) { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param array $match |
191 | 191 | * @return int Rows affected. |
192 | 192 | */ |
193 | - public function update (array $values, array $match): int { |
|
193 | + public function update(array $values, array $match): int { |
|
194 | 194 | foreach ($this->db->quoteArray($values) as $key => $value) { |
195 | 195 | $values[$key] = "{$key} = {$value}"; |
196 | 196 | } |