@@ -330,8 +330,7 @@ |
||
330 | 330 | if ($this->db->isSQLite()) { |
331 | 331 | $info = $this->db->query("PRAGMA table_info({$name})")->fetchAll(); |
332 | 332 | $cols = array_column($info, 'name'); |
333 | - } |
|
334 | - else { |
|
333 | + } else { |
|
335 | 334 | $cols = $this->db->query( |
336 | 335 | "SELECT column_name FROM information_schema.tables WHERE table_name = \"{$name}\"" |
337 | 336 | )->fetchAll(DB::FETCH_COLUMN); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | /** |
197 | 197 | * @param DB $db |
198 | 198 | */ |
199 | - public function __construct (DB $db) { |
|
199 | + public function __construct(DB $db) { |
|
200 | 200 | $this->db = $db; |
201 | 201 | $this->colDefs ??= self::COLUMN_DEFINITIONS[$db->getDriver()]; |
202 | 202 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param int $type |
210 | 210 | * @return $this |
211 | 211 | */ |
212 | - public function addColumn (string $table, string $column, int $type = self::T_STRING) { |
|
212 | + public function addColumn(string $table, string $column, int $type = self::T_STRING) { |
|
213 | 213 | $type = $this->colDefs[$type & self::T_MASK]; |
214 | 214 | $this->db->exec("ALTER TABLE {$table} ADD COLUMN {$column} {$type}"); |
215 | 215 | unset($this->tables[$table]); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param array[] $constraints `[ <TABLE_CONST> => spec ]` |
236 | 236 | * @return $this |
237 | 237 | */ |
238 | - public function createTable (string $table, array $columns, array $constraints = []) { |
|
238 | + public function createTable(string $table, array $columns, array $constraints = []) { |
|
239 | 239 | $defs = $this->toColumnDefinitions($columns); |
240 | 240 | |
241 | 241 | /** @var string[] $pk */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param string $column |
272 | 272 | * @return $this |
273 | 273 | */ |
274 | - public function dropColumn (string $table, string $column) { |
|
274 | + public function dropColumn(string $table, string $column) { |
|
275 | 275 | $this->db->exec("ALTER TABLE {$table} DROP COLUMN {$column}"); |
276 | 276 | unset($this->tables[$table]); |
277 | 277 | return $this; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @param string $table |
284 | 284 | */ |
285 | - public function dropTable (string $table): void { |
|
285 | + public function dropTable(string $table): void { |
|
286 | 286 | $this->db->exec("DROP TABLE IF EXISTS {$table}"); |
287 | 287 | unset($this->tables[$table]); |
288 | 288 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * @return DB |
292 | 292 | */ |
293 | - public function getDb () { |
|
293 | + public function getDb() { |
|
294 | 294 | return $this->db; |
295 | 295 | } |
296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param string $name |
299 | 299 | * @return null|Table |
300 | 300 | */ |
301 | - public function getTable (string $name) { |
|
301 | + public function getTable(string $name) { |
|
302 | 302 | if (!isset($this->tables[$name])) { |
303 | 303 | if ($this->db->isSQLite()) { |
304 | 304 | $info = $this->db->query("PRAGMA table_info({$name})")->fetchAll(); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param string $table |
324 | 324 | * @return bool |
325 | 325 | */ |
326 | - final public function offsetExists ($table): bool { |
|
326 | + final public function offsetExists($table): bool { |
|
327 | 327 | return (bool)$this->offsetGet($table); |
328 | 328 | } |
329 | 329 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @param string $table |
334 | 334 | * @return null|Table |
335 | 335 | */ |
336 | - public function offsetGet ($table) { |
|
336 | + public function offsetGet($table) { |
|
337 | 337 | return $this->getTable($table); |
338 | 338 | } |
339 | 339 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @param $value |
343 | 343 | * @throws LogicException |
344 | 344 | */ |
345 | - final public function offsetSet ($offset, $value) { |
|
345 | + final public function offsetSet($offset, $value) { |
|
346 | 346 | throw new LogicException('The schema cannot be altered this way.'); |
347 | 347 | } |
348 | 348 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param $offset |
351 | 351 | * @throws LogicException |
352 | 352 | */ |
353 | - final public function offsetUnset ($offset) { |
|
353 | + final public function offsetUnset($offset) { |
|
354 | 354 | throw new LogicException('The schema cannot be altered this way.'); |
355 | 355 | } |
356 | 356 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @param string $newName |
363 | 363 | * @return $this |
364 | 364 | */ |
365 | - public function renameColumn (string $table, string $oldName, string $newName) { |
|
365 | + public function renameColumn(string $table, string $oldName, string $newName) { |
|
366 | 366 | $this->db->exec("ALTER TABLE {$table} RENAME COLUMN {$oldName} TO {$newName}"); |
367 | 367 | unset($this->tables[$table]); |
368 | 368 | return $this; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $newName |
376 | 376 | * @return $this |
377 | 377 | */ |
378 | - public function renameTable (string $oldName, string $newName) { |
|
378 | + public function renameTable(string $oldName, string $newName) { |
|
379 | 379 | $this->db->exec("ALTER TABLE {$oldName} RENAME TO {$newName}"); |
380 | 380 | unset($this->tables[$oldName]); |
381 | 381 | return $this; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @param int[] $types |
388 | 388 | * @return int[] |
389 | 389 | */ |
390 | - protected function sortColumns (array $types): array { |
|
390 | + protected function sortColumns(array $types): array { |
|
391 | 391 | uksort($types, function(string $a, string $b) use ($types) { |
392 | 392 | // descending index priority, increasing size, name |
393 | 393 | return $types[$b] <=> $types[$a] ?: $a <=> $b; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param int[] $columns `[ name => <I_CONST> | <T_CONST> ]` |
400 | 400 | * @return string[] |
401 | 401 | */ |
402 | - protected function toColumnDefinitions (array $columns): array { |
|
402 | + protected function toColumnDefinitions(array $columns): array { |
|
403 | 403 | assert(count($columns) > 0); |
404 | 404 | $columns = $this->sortColumns($columns); |
405 | 405 | $defs = []; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param Column $foreign |
425 | 425 | * @return string |
426 | 426 | */ |
427 | - protected function toForeignKeyConstraint (string $table, string $local, Column $foreign): string { |
|
427 | + protected function toForeignKeyConstraint(string $table, string $local, Column $foreign): string { |
|
428 | 428 | return sprintf( |
429 | 429 | 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s) ON DELETE CASCADE', |
430 | 430 | $this->toForeignKeyConstraint_name($table, $local), |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param string $column |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - protected function toForeignKeyConstraint_name (string $table, string $column): string { |
|
444 | + protected function toForeignKeyConstraint_name(string $table, string $column): string { |
|
445 | 445 | return 'FK_' . $table . '__' . $column; |
446 | 446 | } |
447 | 447 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @param string[] $columns |
451 | 451 | * @return string |
452 | 452 | */ |
453 | - protected function toPrimaryKeyConstraint (string $table, array $columns): string { |
|
453 | + protected function toPrimaryKeyConstraint(string $table, array $columns): string { |
|
454 | 454 | return sprintf( |
455 | 455 | 'CONSTRAINT %s PRIMARY KEY (%s)', |
456 | 456 | $this->toPrimaryKeyConstraint_name($table, $columns), |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @param string[] $columns |
466 | 466 | * @return string |
467 | 467 | */ |
468 | - protected function toPrimaryKeyConstraint_name (string $table, array $columns): string { |
|
468 | + protected function toPrimaryKeyConstraint_name(string $table, array $columns): string { |
|
469 | 469 | sort($columns, SORT_STRING); |
470 | 470 | return 'PK_' . $table . '__' . implode('__', $columns); |
471 | 471 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @param string[] $columns |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - protected function toUniqueKeyConstraint (string $table, array $columns): string { |
|
478 | + protected function toUniqueKeyConstraint(string $table, array $columns): string { |
|
479 | 479 | return sprintf( |
480 | 480 | 'CONSTRAINT %s UNIQUE (%s)', |
481 | 481 | $this->toUniqueKeyConstraint_name($table, $columns), |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param string[] $columns |
491 | 491 | * @return string |
492 | 492 | */ |
493 | - protected function toUniqueKeyConstraint_name (string $table, array $columns): string { |
|
493 | + protected function toUniqueKeyConstraint_name(string $table, array $columns): string { |
|
494 | 494 | sort($columns, SORT_STRING); |
495 | 495 | return 'UQ_' . $table . '__' . implode('__', $columns); |
496 | 496 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string|AbstractTable $table |
126 | 126 | * @param string[] $columns |
127 | 127 | */ |
128 | - public function __construct (DB $db, $table, array $columns = ['*']) { |
|
128 | + public function __construct(DB $db, $table, array $columns = ['*']) { |
|
129 | 129 | static $autoAlias = 0; |
130 | 130 | $autoAlias++; |
131 | 131 | parent::__construct($db); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array $args |
153 | 153 | * @return Statement |
154 | 154 | */ |
155 | - public function __invoke (array $args = []) { |
|
155 | + public function __invoke(array $args = []) { |
|
156 | 156 | return $this->execute($args); |
157 | 157 | } |
158 | 158 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - final public function __toString () { |
|
164 | + final public function __toString() { |
|
165 | 165 | return $this->alias; |
166 | 166 | } |
167 | 167 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param array $args Execution arguments. |
172 | 172 | * @return int |
173 | 173 | */ |
174 | - public function count (array $args = []): int { |
|
174 | + public function count(array $args = []): int { |
|
175 | 175 | $clone = clone $this; |
176 | 176 | $clone->_columns = 'COUNT(*)'; |
177 | 177 | $clone->_order = ''; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param array $args |
185 | 185 | * @return Statement |
186 | 186 | */ |
187 | - public function execute (array $args = []) { |
|
187 | + public function execute(array $args = []) { |
|
188 | 188 | if (empty($args)) { |
189 | 189 | return $this->db->query($this->toSql()); |
190 | 190 | } |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | * @param array $args Execution arguments. |
200 | 200 | * @return array |
201 | 201 | */ |
202 | - public function getAll (array $args = []): array { |
|
202 | + public function getAll(array $args = []): array { |
|
203 | 203 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
207 | 207 | * @return Column[] |
208 | 208 | */ |
209 | - public function getColumns () { |
|
209 | + public function getColumns() { |
|
210 | 210 | return $this->refs; |
211 | 211 | } |
212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param array $args Execution arguments. |
220 | 220 | * @return Generator |
221 | 221 | */ |
222 | - public function getEach (array $args = []) { |
|
222 | + public function getEach(array $args = []) { |
|
223 | 223 | yield from $this->fetcher->__invoke($this->execute($args)); |
224 | 224 | } |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param array $args |
232 | 232 | * @return mixed |
233 | 233 | */ |
234 | - public function getFirst (array $args = []) { |
|
234 | + public function getFirst(array $args = []) { |
|
235 | 235 | return $this->getEach($args)->current(); |
236 | 236 | } |
237 | 237 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return Generator |
244 | 244 | */ |
245 | - public function getIterator () { |
|
245 | + public function getIterator() { |
|
246 | 246 | yield from $this->getEach(); |
247 | 247 | } |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return null|mixed |
254 | 254 | */ |
255 | - public function getResult (array $args = []) { |
|
255 | + public function getResult(array $args = []) { |
|
256 | 256 | return $this->execute($args)->fetchColumn(); |
257 | 257 | } |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param string $column |
263 | 263 | * @return $this |
264 | 264 | */ |
265 | - public function group (string $column) { |
|
265 | + public function group(string $column) { |
|
266 | 266 | if (!strlen($this->_group)) { |
267 | 267 | $this->_group = " GROUP BY {$column}"; |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string ...$conditions |
279 | 279 | * @return $this |
280 | 280 | */ |
281 | - public function having (string ...$conditions) { |
|
281 | + public function having(string ...$conditions) { |
|
282 | 282 | assert(count($conditions) > 0); |
283 | 283 | $conditions = implode(' AND ', $conditions); |
284 | 284 | if (!strlen($this->_having)) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param Select $select |
299 | 299 | * @return $this |
300 | 300 | */ |
301 | - public function intersect (Select $select) { |
|
301 | + public function intersect(Select $select) { |
|
302 | 302 | if ($this->db->isMySQL()) { |
303 | 303 | // to be standards compliant, this hack must fail if they don't have the same cols. |
304 | 304 | assert(count($this->refs) === count($select->refs) and !array_diff_key($this->refs, $select->refs)); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return Predicate |
321 | 321 | */ |
322 | - public function isEmpty () { |
|
322 | + public function isEmpty() { |
|
323 | 323 | return Predicate::factory($this->db, "NOT EXISTS ({$this->toSql()})"); |
324 | 324 | } |
325 | 325 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return Predicate |
330 | 330 | */ |
331 | - public function isNotEmpty () { |
|
331 | + public function isNotEmpty() { |
|
332 | 332 | return Predicate::factory($this->db, "EXISTS ({$this->toSql()})"); |
333 | 333 | } |
334 | 334 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @param string ...$conditions |
340 | 340 | * @return $this |
341 | 341 | */ |
342 | - public function join ($table, string ...$conditions) { |
|
342 | + public function join($table, string ...$conditions) { |
|
343 | 343 | assert(count($conditions) > 0); |
344 | 344 | if ($table instanceof Select) { |
345 | 345 | $table = $table->toSubquery(); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param string ...$conditions |
357 | 357 | * @return $this |
358 | 358 | */ |
359 | - public function joinLeft ($table, string ...$conditions) { |
|
359 | + public function joinLeft($table, string ...$conditions) { |
|
360 | 360 | assert(count($conditions) > 0); |
361 | 361 | if ($table instanceof Select) { |
362 | 362 | $table = $table->toSubquery(); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @param int $offset |
374 | 374 | * @return $this |
375 | 375 | */ |
376 | - public function limit (int $limit, int $offset = 0) { |
|
376 | + public function limit(int $limit, int $offset = 0) { |
|
377 | 377 | if ($limit == 0) { |
378 | 378 | $this->_limit = ''; |
379 | 379 | } |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @param int|string $ref Ordinal or reference name. |
393 | 393 | * @return null|Column |
394 | 394 | */ |
395 | - public function offsetGet ($ref) { |
|
395 | + public function offsetGet($ref) { |
|
396 | 396 | if (is_int($ref)) { |
397 | 397 | return current(array_slice($this->refs, $ref, 1)) ?: null; |
398 | 398 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @param string $order |
406 | 406 | * @return $this |
407 | 407 | */ |
408 | - public function order (string $order) { |
|
408 | + public function order(string $order) { |
|
409 | 409 | if (strlen($order)) { |
410 | 410 | $order = " ORDER BY {$order}"; |
411 | 411 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * @return Statement |
418 | 418 | */ |
419 | - public function prepare () { |
|
419 | + public function prepare() { |
|
420 | 420 | return $this->db->prepare($this->toSql()); |
421 | 421 | } |
422 | 422 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $alias |
425 | 425 | * @return $this |
426 | 426 | */ |
427 | - public function setAlias (string $alias) { |
|
427 | + public function setAlias(string $alias) { |
|
428 | 428 | $this->alias = $alias; |
429 | 429 | foreach ($this->refs as $k => $column) { |
430 | 430 | $this->refs[$k] = $column->setQualifier($alias); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param string[] $expressions Keyed by alias if applicable. |
442 | 442 | * @return $this |
443 | 443 | */ |
444 | - public function setColumns (array $expressions = ['*']) { |
|
444 | + public function setColumns(array $expressions = ['*']) { |
|
445 | 445 | if ($expressions === ['*']) { |
446 | 446 | $expressions = array_keys($this->table->getColumns()); |
447 | 447 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * @param Closure $fetcher |
470 | 470 | * @return $this |
471 | 471 | */ |
472 | - public function setFetcher (Closure $fetcher) { |
|
472 | + public function setFetcher(Closure $fetcher) { |
|
473 | 473 | $this->fetcher = $fetcher; |
474 | 474 | return $this; |
475 | 475 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - public function toSql (): string { |
|
482 | + public function toSql(): string { |
|
483 | 483 | $sql = "SELECT {$this->_columns} FROM {$this->_table}"; |
484 | 484 | $sql .= $this->_join; |
485 | 485 | $sql .= $this->_where; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return string |
498 | 498 | */ |
499 | - public function toSubquery (): string { |
|
499 | + public function toSubquery(): string { |
|
500 | 500 | return "({$this->toSql()}) AS {$this->alias}"; |
501 | 501 | } |
502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param Select $select |
507 | 507 | * @return $this |
508 | 508 | */ |
509 | - public function union (Select $select) { |
|
509 | + public function union(Select $select) { |
|
510 | 510 | $select = clone $select; |
511 | 511 | $select->_order = ''; |
512 | 512 | $select->_limit = ''; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param Select $select |
521 | 521 | * @return $this |
522 | 522 | */ |
523 | - public function unionAll (Select $select) { |
|
523 | + public function unionAll(Select $select) { |
|
524 | 524 | $select = clone $select; |
525 | 525 | $select->_order = ''; |
526 | 526 | $select->_limit = ''; |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @param string ...$conditions |
535 | 535 | * @return $this |
536 | 536 | */ |
537 | - public function where (string ...$conditions) { |
|
537 | + public function where(string ...$conditions) { |
|
538 | 538 | assert(count($conditions) > 0); |
539 | 539 | $conditions = implode(' AND ', $conditions); |
540 | 540 | if (!strlen($this->_where)) { |
@@ -132,8 +132,7 @@ discard block |
||
132 | 132 | if ($table instanceof Select) { |
133 | 133 | $this->_table = $table->toSubquery(); |
134 | 134 | $this->alias = "_anon{$autoAlias}_{$table->alias}"; |
135 | - } |
|
136 | - else { |
|
135 | + } else { |
|
137 | 136 | if (is_string($table)) { |
138 | 137 | $table = $db[$table]; |
139 | 138 | assert(isset($table)); |
@@ -265,8 +264,7 @@ discard block |
||
265 | 264 | public function group (string $column) { |
266 | 265 | if (!strlen($this->_group)) { |
267 | 266 | $this->_group = " GROUP BY {$column}"; |
268 | - } |
|
269 | - else { |
|
267 | + } else { |
|
270 | 268 | $this->_group .= ", {$column}"; |
271 | 269 | } |
272 | 270 | return $this; |
@@ -283,8 +281,7 @@ discard block |
||
283 | 281 | $conditions = implode(' AND ', $conditions); |
284 | 282 | if (!strlen($this->_having)) { |
285 | 283 | $this->_having = " HAVING {$conditions}"; |
286 | - } |
|
287 | - else { |
|
284 | + } else { |
|
288 | 285 | $this->_having .= " AND {$conditions}"; |
289 | 286 | } |
290 | 287 | return $this; |
@@ -376,8 +373,7 @@ discard block |
||
376 | 373 | public function limit (int $limit, int $offset = 0) { |
377 | 374 | if ($limit == 0) { |
378 | 375 | $this->_limit = ''; |
379 | - } |
|
380 | - else { |
|
376 | + } else { |
|
381 | 377 | $this->_limit = " LIMIT {$limit}"; |
382 | 378 | if ($offset > 1) { |
383 | 379 | $this->_limit .= " OFFSET {$offset}"; |
@@ -452,8 +448,7 @@ discard block |
||
452 | 448 | $name = $match['name'] ?? null; |
453 | 449 | if (is_int($alias)) { |
454 | 450 | $alias = $name; |
455 | - } |
|
456 | - elseif ($alias !== $name) { |
|
451 | + } elseif ($alias !== $name) { |
|
457 | 452 | $expr .= " AS {$alias}"; |
458 | 453 | } |
459 | 454 | if (isset($alias)) { |
@@ -539,8 +534,7 @@ discard block |
||
539 | 534 | $conditions = implode(' AND ', $conditions); |
540 | 535 | if (!strlen($this->_where)) { |
541 | 536 | $this->_where = " WHERE {$conditions}"; |
542 | - } |
|
543 | - else { |
|
537 | + } else { |
|
544 | 538 | $this->_where .= " AND {$conditions}"; |
545 | 539 | } |
546 | 540 | return $this; |
@@ -114,8 +114,7 @@ |
||
114 | 114 | $slots = implode(',', $this->db->slots(array_keys($this->columns))); |
115 | 115 | if ($this->db->isSQLite()) { |
116 | 116 | $sql = "INSERT OR IGNORE INTO {$this} ({$columns}) VALUES ({$slots})"; |
117 | - } |
|
118 | - else { |
|
117 | + } else { |
|
119 | 118 | $sql = "INSERT IGNORE INTO {$this} ({$columns}) VALUES ({$slots})"; |
120 | 119 | } |
121 | 120 | return $this->db->prepare($sql); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $interface |
35 | 35 | * @return Junction |
36 | 36 | */ |
37 | - public static function fromInterface (DB $db, string $interface) { |
|
37 | + public static function fromInterface(DB $db, string $interface) { |
|
38 | 38 | $ref = new ReflectionClass($interface); |
39 | 39 | assert($ref->isInterface()); |
40 | 40 | $doc = $ref->getDocComment(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $table |
50 | 50 | * @param string[] $classes |
51 | 51 | */ |
52 | - public function __construct (DB $db, string $table, array $classes) { |
|
52 | + public function __construct(DB $db, string $table, array $classes) { |
|
53 | 53 | parent::__construct($db, $table, array_keys($classes)); |
54 | 54 | $this->classes = $classes; |
55 | 55 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param array $match Keyed by junction column. |
64 | 64 | * @return Select|EntityInterface[] |
65 | 65 | */ |
66 | - public function findAll (string $key, array $match = []) { |
|
66 | + public function findAll(string $key, array $match = []) { |
|
67 | 67 | $record = $this->getRecord($key); |
68 | 68 | $select = $record->loadAll(); |
69 | 69 | $select->join($this, $this[$key]->isEqual($record['id'])); |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | * @param string $column |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - final public function getClass (string $column): string { |
|
80 | + final public function getClass(string $column): string { |
|
81 | 81 | return $this->classes[$column]; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @return string[] |
86 | 86 | */ |
87 | - final public function getClasses () { |
|
87 | + final public function getClasses() { |
|
88 | 88 | return $this->classes; |
89 | 89 | } |
90 | 90 | |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * @param string $column |
93 | 93 | * @return Record |
94 | 94 | */ |
95 | - public function getRecord (string $column) { |
|
95 | + public function getRecord(string $column) { |
|
96 | 96 | return $this->db->getRecord($this->classes[$column]); |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return Record[] |
101 | 101 | */ |
102 | - public function getRecords () { |
|
102 | + public function getRecords() { |
|
103 | 103 | return array_map(fn($class) => $this->db->getRecord($class), $this->classes); |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param int[] $ids Keyed by column. |
110 | 110 | * @return int Rows affected. |
111 | 111 | */ |
112 | - public function link (array $ids): int { |
|
112 | + public function link(array $ids): int { |
|
113 | 113 | $statement = $this->cache(__FUNCTION__, function() { |
114 | 114 | $columns = implode(',', array_keys($this->columns)); |
115 | 115 | $slots = implode(',', $this->db->slots(array_keys($this->columns))); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param array $ids Keyed by Column |
133 | 133 | * @return int Rows affected |
134 | 134 | */ |
135 | - public function unlink (array $ids): int { |
|
135 | + public function unlink(array $ids): int { |
|
136 | 136 | return $this->delete($ids); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param DB $db |
35 | 35 | * @param string $dir |
36 | 36 | */ |
37 | - public function __construct (DB $db, string $dir) { |
|
37 | + public function __construct(DB $db, string $dir) { |
|
38 | 38 | $this->db = $db; |
39 | 39 | $this->dir = $dir; |
40 | 40 | $this->table ??= $db['__migrations__'] ?? $db->getSchema()->createTable('__migrations__', [ |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param string $to Migration sequence identifier, or `null` to step down once. |
49 | 49 | * @return null|string The resulting current sequence identifier. |
50 | 50 | */ |
51 | - public function down (string $to = null): ?string { |
|
51 | + public function down(string $to = null): ?string { |
|
52 | 52 | return $this->db->transact(function() use ($to) { |
53 | 53 | $current = $this->getCurrent(); |
54 | 54 | // walk newest to oldest |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return null|string |
77 | 77 | */ |
78 | - public function getCurrent (): ?string { |
|
78 | + public function getCurrent(): ?string { |
|
79 | 79 | return $this->table->select([$this->table['sequence']->max()])->getResult(); |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - final public function getDir (): string { |
|
85 | + final public function getDir(): string { |
|
86 | 86 | return $this->dir; |
87 | 87 | } |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param array $spec |
91 | 91 | * @return MigrationInterface |
92 | 92 | */ |
93 | - protected function getMigration (string $file) { |
|
93 | + protected function getMigration(string $file) { |
|
94 | 94 | $migration = include "{$file}"; |
95 | 95 | assert($migration instanceof MigrationInterface); |
96 | 96 | return $migration; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string[] [ sequence => file ] |
103 | 103 | */ |
104 | - protected function glob () { |
|
104 | + protected function glob() { |
|
105 | 105 | $files = []; |
106 | 106 | foreach (glob("{$this->dir}/*.php") as $file) { |
107 | 107 | $files[basename($file, '.php')] = $file; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param null|string $to Migration sequence identifier, or `null` for all upgrades. |
116 | 116 | * @return null|string The resulting current sequence identifier. |
117 | 117 | */ |
118 | - public function up (string $to = null): ?string { |
|
118 | + public function up(string $to = null): ?string { |
|
119 | 119 | return $this->db->transact(function() use ($to) { |
120 | 120 | $current = $this->getCurrent(); |
121 | 121 | // walk oldest to newest |
@@ -31,11 +31,11 @@ |
||
31 | 31 | * @param Schema $schema |
32 | 32 | * @return void |
33 | 33 | */ |
34 | - public function down ($schema); |
|
34 | + public function down($schema); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @param Schema $schema |
38 | 38 | * @return void |
39 | 39 | */ |
40 | - public function up ($schema); |
|
40 | + public function up($schema); |
|
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
271 | 271 | return; |
272 | 272 | |
273 | 273 | default: |
274 | - $usage(); |
|
275 | - exit(1); |
|
276 | -} |
|
277 | 274 | \ No newline at end of file |
275 | + $usage |
|
278 | 276 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
271 | 271 | return; |
272 | 272 | |
273 | 273 | default: |
274 | - $usage(); |
|
275 | - exit(1); |
|
276 | -} |
|
277 | 274 | \ No newline at end of file |
275 | + $usage |
|
278 | 276 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
271 | 271 | return; |
272 | 272 | |
273 | 273 | default: |
274 | - $usage(); |
|
275 | - exit(1); |
|
276 | -} |
|
277 | 274 | \ No newline at end of file |
275 | + $usage |
|
278 | 276 | \ No newline at end of file |
@@ -271,6 +271,4 @@ |
||
271 | 271 | return; |
272 | 272 | |
273 | 273 | default: |
274 | - $usage(); |
|
275 | - exit(1); |
|
276 | -} |
|
277 | 274 | \ No newline at end of file |
275 | + $usage |
|
278 | 276 | \ No newline at end of file |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | }; |
146 | 146 | if ($access instanceof Record) { |
147 | 147 | // create table |
148 | - if (!$db[$access->getName()]) { |
|
148 | + if (!$db[$access - >getName()]) { |
|
149 | 149 | $columns = []; |
150 | 150 | foreach ($access->getTypes() as $property => $type) { |
151 | 151 | $T_CONST = Schema::PHP_TYPE_NAMES[$type]; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // check each eav |
164 | 164 | foreach ($access->getEav() as $eav) { |
165 | 165 | // create table |
166 | - if (!$db[$eav->getName()]) { |
|
166 | + if (!$db[$eav - >getName()]) { |
|
167 | 167 | $T_CONST = Schema::PHP_TYPE_NAMES[$eav->getType()]; |
168 | 168 | $columns = [ |
169 | 169 | "'entity' => Schema::T_INT_STRICT", |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | elseif ($access instanceof Junction) { |
185 | 185 | // create table |
186 | - if (!$db[$access->getName()]) { |
|
186 | + if (!$db[$access - >getName()]) { |
|
187 | 187 | $records = $access->getRecords(); |
188 | 188 | $columns = array_map( |
189 | 189 | fn(string $column) => "'{$column}' => Schema::T_INT_STRICT", |
@@ -271,6 +271,4 @@ discard block |
||
271 | 271 | return; |
272 | 272 | |
273 | 273 | default: |
274 | - $usage(); |
|
275 | - exit(1); |
|
276 | -} |
|
277 | 274 | \ No newline at end of file |
275 | + $usage |
|
278 | 276 | \ No newline at end of file |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string|EntityInterface $class |
88 | 88 | * @return Record |
89 | 89 | */ |
90 | - public static function fromClass (DB $db, $class) { |
|
90 | + public static function fromClass(DB $db, $class) { |
|
91 | 91 | $rClass = new ReflectionClass($class); |
92 | 92 | assert($rClass->isInstantiable()); |
93 | 93 | $columns = []; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string[] $columns Property names. |
117 | 117 | * @param EAV[] $eav Keyed by property name. |
118 | 118 | */ |
119 | - public function __construct (DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
119 | + public function __construct(DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
120 | 120 | parent::__construct($db, $table, $columns); |
121 | 121 | $this->proto = $proto; |
122 | 122 | $rClass = new ReflectionClass($proto); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param Statement $statement |
166 | 166 | * @return EntityInterface[] Keyed by ID |
167 | 167 | */ |
168 | - public function fetchAll (Statement $statement): array { |
|
168 | + public function fetchAll(Statement $statement): array { |
|
169 | 169 | return iterator_to_array($this->fetchEach($statement)); |
170 | 170 | } |
171 | 171 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param Statement $statement |
177 | 177 | * @return Generator|EntityInterface[] Keyed by ID |
178 | 178 | */ |
179 | - public function fetchEach (Statement $statement) { |
|
179 | + public function fetchEach(Statement $statement) { |
|
180 | 180 | do { |
181 | 181 | $entities = []; |
182 | 182 | for ($i = 0; $i < 256 and false !== $row = $statement->fetch(); $i++) { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param array[] $eavMatch `[eav property => attribute => value]` |
199 | 199 | * @return Select|EntityInterface[] |
200 | 200 | */ |
201 | - public function findAll (array $match, array $eavMatch = []) { |
|
201 | + public function findAll(array $match, array $eavMatch = []) { |
|
202 | 202 | $select = $this->loadAll(); |
203 | 203 | foreach ($match as $a => $b) { |
204 | 204 | $select->where($this->db->match($this[$a] ?? $a, $b)); |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | * @param array $eavMatch `[eav property => attribute => value]` |
218 | 218 | * @return null|EntityInterface |
219 | 219 | */ |
220 | - public function findFirst (array $match, array $eavMatch = []) { |
|
220 | + public function findFirst(array $match, array $eavMatch = []) { |
|
221 | 221 | return $this->findAll($match, $eavMatch)->limit(1)->getFirst(); |
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - final public function getClass (): string { |
|
227 | + final public function getClass(): string { |
|
228 | 228 | return get_class($this->proto); |
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
232 | 232 | * @return EAV[] |
233 | 233 | */ |
234 | - public function getEav () { |
|
234 | + public function getEav() { |
|
235 | 235 | return $this->eav; |
236 | 236 | } |
237 | 237 | |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string[] |
242 | 242 | */ |
243 | - final public function getProperties (): array { |
|
243 | + final public function getProperties(): array { |
|
244 | 244 | return array_keys($this->properties); |
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
248 | 248 | * @return EntityInterface |
249 | 249 | */ |
250 | - public function getProto () { |
|
250 | + public function getProto() { |
|
251 | 251 | return $this->proto; |
252 | 252 | } |
253 | 253 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return string[] |
260 | 260 | */ |
261 | - final public function getTypes (): array { |
|
261 | + final public function getTypes(): array { |
|
262 | 262 | return $this->types; |
263 | 263 | } |
264 | 264 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param EntityInterface $entity |
267 | 267 | * @return array |
268 | 268 | */ |
269 | - protected function getValues (EntityInterface $entity): array { |
|
269 | + protected function getValues(EntityInterface $entity): array { |
|
270 | 270 | $values = []; |
271 | 271 | foreach (array_keys($this->columns) as $name) { |
272 | 272 | $values[$name] = $this->properties[$name]->getValue($entity); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $property |
279 | 279 | * @return bool |
280 | 280 | */ |
281 | - final public function isNullable (string $property): bool { |
|
281 | + final public function isNullable(string $property): bool { |
|
282 | 282 | return $this->nullable[$property]; |
283 | 283 | } |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param int $id |
289 | 289 | * @return null|EntityInterface |
290 | 290 | */ |
291 | - public function load (int $id) { |
|
291 | + public function load(int $id) { |
|
292 | 292 | $statement = $this->cache(__FUNCTION__, function() { |
293 | 293 | return $this->select()->where('id = ?')->prepare(); |
294 | 294 | }); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return Select|EntityInterface[] |
310 | 310 | */ |
311 | - public function loadAll () { |
|
311 | + public function loadAll() { |
|
312 | 312 | return $this->select()->setFetcher(function(Statement $statement) { |
313 | 313 | yield from $this->fetchEach($statement); |
314 | 314 | }); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @param EntityInterface[] $entities |
321 | 321 | */ |
322 | - protected function loadEav (array $entities): void { |
|
322 | + protected function loadEav(array $entities): void { |
|
323 | 323 | $ids = array_keys($entities); |
324 | 324 | foreach ($this->eav as $name => $eav) { |
325 | 325 | foreach ($eav->loadAll($ids) as $id => $values) { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param EntityInterface $entity |
335 | 335 | * @return int ID |
336 | 336 | */ |
337 | - public function save (EntityInterface $entity): int { |
|
337 | + public function save(EntityInterface $entity): int { |
|
338 | 338 | if (!$entity->getId()) { |
339 | 339 | $this->saveInsert($entity); |
340 | 340 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | /** |
349 | 349 | * @param EntityInterface $entity |
350 | 350 | */ |
351 | - protected function saveEav (EntityInterface $entity): void { |
|
351 | + protected function saveEav(EntityInterface $entity): void { |
|
352 | 352 | $id = $entity->getId(); |
353 | 353 | foreach ($this->eav as $name => $eav) { |
354 | 354 | // may be null to skip |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @param EntityInterface $entity |
366 | 366 | */ |
367 | - protected function saveInsert (EntityInterface $entity): void { |
|
367 | + protected function saveInsert(EntityInterface $entity): void { |
|
368 | 368 | $statement = $this->cache(__FUNCTION__, function() { |
369 | 369 | $slots = $this->db->slots(array_keys($this->columns)); |
370 | 370 | unset($slots['id']); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @param EntityInterface $entity |
385 | 385 | */ |
386 | - protected function saveUpdate (EntityInterface $entity): void { |
|
386 | + protected function saveUpdate(EntityInterface $entity): void { |
|
387 | 387 | $statement = $this->cache(__FUNCTION__, function() { |
388 | 388 | $slots = $this->db->slotsEqual(array_keys($this->columns)); |
389 | 389 | unset($slots['id']); |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @param EntityInterface $proto |
399 | 399 | * @return $this |
400 | 400 | */ |
401 | - public function setProto (EntityInterface $proto) { |
|
401 | + public function setProto(EntityInterface $proto) { |
|
402 | 402 | $this->proto = $proto; |
403 | 403 | return $this; |
404 | 404 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param mixed $value |
411 | 411 | * @return mixed |
412 | 412 | */ |
413 | - protected function setType (string $property, $value) { |
|
413 | + protected function setType(string $property, $value) { |
|
414 | 414 | if (isset($value)) { |
415 | 415 | // doesn't care about the type's letter case |
416 | 416 | settype($value, $this->types[$property]); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param EntityInterface $entity |
423 | 423 | * @param array $values |
424 | 424 | */ |
425 | - protected function setValues (EntityInterface $entity, array $values): void { |
|
425 | + protected function setValues(EntityInterface $entity, array $values): void { |
|
426 | 426 | foreach ($values as $name => $value) { |
427 | 427 | if (isset($this->properties[$name])) { |
428 | 428 | $this->properties[$name]->setValue($entity, $this->setType($name, $value)); |
@@ -96,8 +96,7 @@ discard block |
||
96 | 96 | $doc = $rProp->getDocComment(); |
97 | 97 | if (preg_match(static::RX_IS_COLUMN, $doc)) { |
98 | 98 | $columns[] = $rProp->getName(); |
99 | - } |
|
100 | - elseif (preg_match(static::RX_EAV, $doc, $eav)) { |
|
99 | + } elseif (preg_match(static::RX_EAV, $doc, $eav)) { |
|
101 | 100 | preg_match(static::RX_EAV_VAR, $doc, $var); |
102 | 101 | $EAV[$rProp->getName()] = EAV::factory($db, $eav['table'], $var['type'] ?? 'string'); |
103 | 102 | } |
@@ -337,8 +336,7 @@ discard block |
||
337 | 336 | public function save (EntityInterface $entity): int { |
338 | 337 | if (!$entity->getId()) { |
339 | 338 | $this->saveInsert($entity); |
340 | - } |
|
341 | - else { |
|
339 | + } else { |
|
342 | 340 | $this->saveUpdate($entity); |
343 | 341 | } |
344 | 342 | $this->saveEav($entity); |
@@ -426,8 +424,7 @@ discard block |
||
426 | 424 | foreach ($values as $name => $value) { |
427 | 425 | if (isset($this->properties[$name])) { |
428 | 426 | $this->properties[$name]->setValue($entity, $this->setType($name, $value)); |
429 | - } |
|
430 | - else { |
|
427 | + } else { |
|
431 | 428 | // attempt to set unknown fields directly on the instance. |
432 | 429 | $entity->{$name} = $value; |
433 | 430 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $name |
24 | 24 | * @param string $type |
25 | 25 | */ |
26 | - public function __construct (DB $db, string $name, string $type = 'string') { |
|
26 | + public function __construct(DB $db, string $name, string $type = 'string') { |
|
27 | 27 | parent::__construct($db, $name, ['entity', 'attribute', 'value']); |
28 | 28 | $this->type = $type; |
29 | 29 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param string $attribute |
36 | 36 | * @return bool |
37 | 37 | */ |
38 | - public function exists (int $id, string $attribute): bool { |
|
38 | + public function exists(int $id, string $attribute): bool { |
|
39 | 39 | $statement = $this->cache(__FUNCTION__, function() { |
40 | 40 | return $this->select(['COUNT(*) > 0'])->where('entity = ? AND attribute = ?')->prepare(); |
41 | 41 | }); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute. |
54 | 54 | * @return Select |
55 | 55 | */ |
56 | - public function findAll (array $match) { |
|
56 | + public function findAll(array $match) { |
|
57 | 57 | $select = $this->select([$this['entity']]); |
58 | 58 | $prior = $this; |
59 | 59 | foreach ($match as $attribute => $value) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @return string |
74 | 74 | */ |
75 | - final public function getType (): string { |
|
75 | + final public function getType(): string { |
|
76 | 76 | return $this->type; |
77 | 77 | } |
78 | 78 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int $id |
83 | 83 | * @return array `[attribute => value]` |
84 | 84 | */ |
85 | - public function load (int $id): array { |
|
85 | + public function load(int $id): array { |
|
86 | 86 | $statement = $this->cache(__FUNCTION__, function() { |
87 | 87 | $select = $this->select(['attribute', 'value']); |
88 | 88 | $select->where('entity = ?'); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param int[] $ids |
99 | 99 | * @return array[] `[id => attribute => value] |
100 | 100 | */ |
101 | - public function loadAll (array $ids): array { |
|
101 | + public function loadAll(array $ids): array { |
|
102 | 102 | if (empty($ids)) { |
103 | 103 | return []; |
104 | 104 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param array $values `[attribute => value]` |
124 | 124 | * @return $this |
125 | 125 | */ |
126 | - public function save (int $id, array $values) { |
|
126 | + public function save(int $id, array $values) { |
|
127 | 127 | $this->delete([ |
128 | 128 | $this['entity']->isEqual($id), |
129 | 129 | $this['attribute']->isNotEqual(array_keys($values)) |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param mixed $value |
152 | 152 | * @return null|scalar |
153 | 153 | */ |
154 | - protected function setType ($value) { |
|
154 | + protected function setType($value) { |
|
155 | 155 | if (isset($value)) { |
156 | 156 | settype($value, $this->type); |
157 | 157 | } |