@@ -14,7 +14,7 @@ |
||
| 14 | 14 | * |
| 15 | 15 | * @return Text |
| 16 | 16 | */ |
| 17 | - public function toText () { |
|
| 17 | + public function toText() { |
|
| 18 | 18 | if ($this->db == 'sqlite') { |
| 19 | 19 | return new Text($this->db, "CAST({$this} AS TEXT)"); |
| 20 | 20 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param string|Select $table |
| 104 | 104 | * @param string[] $columns |
| 105 | 105 | */ |
| 106 | - public function __construct (DB $db, $table, array $columns) { |
|
| 106 | + public function __construct(DB $db, $table, array $columns) { |
|
| 107 | 107 | parent::__construct($db); |
| 108 | 108 | if ($table instanceof Select) { |
| 109 | 109 | $this->table = $table->toSubquery(); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param array $args |
| 124 | 124 | * @return Statement |
| 125 | 125 | */ |
| 126 | - public function __invoke (array $args = []) { |
|
| 126 | + public function __invoke(array $args = []) { |
|
| 127 | 127 | return $this->execute($args); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - final public function __toString () { |
|
| 135 | + final public function __toString() { |
|
| 136 | 136 | return $this->alias; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param array $args Execution arguments. |
| 143 | 143 | * @return int |
| 144 | 144 | */ |
| 145 | - public function count (array $args = []): int { |
|
| 145 | + public function count(array $args = []): int { |
|
| 146 | 146 | $clone = clone $this; |
| 147 | 147 | $clone->_columns = 'COUNT(*)'; |
| 148 | 148 | $clone->_order = ''; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param array $args |
| 156 | 156 | * @return Statement |
| 157 | 157 | */ |
| 158 | - public function execute (array $args = []) { |
|
| 158 | + public function execute(array $args = []) { |
|
| 159 | 159 | if (empty($args)) { |
| 160 | 160 | return $this->db->query($this->toSql()); |
| 161 | 161 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param array $args Execution arguments. |
| 171 | 171 | * @return array |
| 172 | 172 | */ |
| 173 | - public function getAll (array $args = []): array { |
|
| 173 | + public function getAll(array $args = []): array { |
|
| 174 | 174 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param array $args Execution arguments. |
| 184 | 184 | * @return Generator |
| 185 | 185 | */ |
| 186 | - public function getEach (array $args = []) { |
|
| 186 | + public function getEach(array $args = []) { |
|
| 187 | 187 | yield from $this->fetcher->__invoke($this->execute($args)); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param array $args |
| 196 | 196 | * @return mixed |
| 197 | 197 | */ |
| 198 | - public function getFirst (array $args = []) { |
|
| 198 | + public function getFirst(array $args = []) { |
|
| 199 | 199 | return $this->getEach($args)->current(); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return Generator |
| 208 | 208 | */ |
| 209 | - public function getIterator () { |
|
| 209 | + public function getIterator() { |
|
| 210 | 210 | yield from $this->getEach(); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param string $column |
| 217 | 217 | * @return $this |
| 218 | 218 | */ |
| 219 | - public function group (string $column) { |
|
| 219 | + public function group(string $column) { |
|
| 220 | 220 | if (!strlen($this->_group)) { |
| 221 | 221 | $this->_group = " GROUP BY {$column}"; |
| 222 | 222 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @param string $condition |
| 233 | 233 | * @return $this |
| 234 | 234 | */ |
| 235 | - public function having (string $condition) { |
|
| 235 | + public function having(string $condition) { |
|
| 236 | 236 | if (!strlen($this->_having)) { |
| 237 | 237 | $this->_having = " HAVING {$condition}"; |
| 238 | 238 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return Predicate |
| 249 | 249 | */ |
| 250 | - public function isCorrelated () { |
|
| 250 | + public function isCorrelated() { |
|
| 251 | 251 | return new Predicate("EXISTS ({$this->toSql()})"); |
| 252 | 252 | } |
| 253 | 253 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return Predicate |
| 258 | 258 | */ |
| 259 | - public function isNotCorrelated () { |
|
| 259 | + public function isNotCorrelated() { |
|
| 260 | 260 | return new Predicate("NOT EXISTS ({$this->toSql()})"); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @param string $type |
| 269 | 269 | * @return $this |
| 270 | 270 | */ |
| 271 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
| 271 | + public function join($table, string $condition, string $type = 'INNER') { |
|
| 272 | 272 | if ($table instanceof Select) { |
| 273 | 273 | $table = $table->toSubquery(); |
| 274 | 274 | } |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * @param int $offset |
| 284 | 284 | * @return $this |
| 285 | 285 | */ |
| 286 | - public function limit (int $limit, int $offset = 0) { |
|
| 286 | + public function limit(int $limit, int $offset = 0) { |
|
| 287 | 287 | if ($limit == 0) { |
| 288 | 288 | $this->_limit = ''; |
| 289 | 289 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param mixed $offset Ordinal or reference name. |
| 303 | 303 | * @return bool |
| 304 | 304 | */ |
| 305 | - public function offsetExists ($offset): bool { |
|
| 305 | + public function offsetExists($offset): bool { |
|
| 306 | 306 | return isset($this->references[$offset]); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @param mixed $offset Ordinal or reference name. |
| 313 | 313 | * @return Column |
| 314 | 314 | */ |
| 315 | - public function offsetGet ($offset) { |
|
| 315 | + public function offsetGet($offset) { |
|
| 316 | 316 | return $this->references[$offset]; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @param string $order |
| 323 | 323 | * @return $this |
| 324 | 324 | */ |
| 325 | - public function order (string $order) { |
|
| 325 | + public function order(string $order) { |
|
| 326 | 326 | if (strlen($order)) { |
| 327 | 327 | $order = " ORDER BY {$order}"; |
| 328 | 328 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | /** |
| 334 | 334 | * @return Statement |
| 335 | 335 | */ |
| 336 | - public function prepare () { |
|
| 336 | + public function prepare() { |
|
| 337 | 337 | return $this->db->prepare($this->toSql()); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param string $alias |
| 342 | 342 | * @return $this |
| 343 | 343 | */ |
| 344 | - public function setAlias (string $alias) { |
|
| 344 | + public function setAlias(string $alias) { |
|
| 345 | 345 | $this->alias = $alias; |
| 346 | 346 | return $this; |
| 347 | 347 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @param string[] $columns |
| 351 | 351 | * @return $this |
| 352 | 352 | */ |
| 353 | - public function setColumns (array $columns) { |
|
| 353 | + public function setColumns(array $columns) { |
|
| 354 | 354 | $this->references = []; |
| 355 | 355 | $_columns = []; |
| 356 | 356 | $i = 0; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @param Closure $fetcher |
| 381 | 381 | * @return $this |
| 382 | 382 | */ |
| 383 | - public function setFetcher (Closure $fetcher) { |
|
| 383 | + public function setFetcher(Closure $fetcher) { |
|
| 384 | 384 | $this->fetcher = $fetcher; |
| 385 | 385 | return $this; |
| 386 | 386 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return string |
| 392 | 392 | */ |
| 393 | - public function toSql (): string { |
|
| 393 | + public function toSql(): string { |
|
| 394 | 394 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
| 395 | 395 | $sql .= $this->_join; |
| 396 | 396 | $sql .= $this->_where; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * |
| 407 | 407 | * @return string |
| 408 | 408 | */ |
| 409 | - public function toSubquery (): string { |
|
| 409 | + public function toSubquery(): string { |
|
| 410 | 410 | return "({$this->toSql()}) AS {$this->alias}"; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | * @param string $condition |
| 417 | 417 | * @return $this |
| 418 | 418 | */ |
| 419 | - public function where (string $condition) { |
|
| 419 | + public function where(string $condition) { |
|
| 420 | 420 | if (!strlen($this->_where)) { |
| 421 | 421 | $this->_where = " WHERE {$condition}"; |
| 422 | 422 | } |
@@ -108,8 +108,7 @@ discard block |
||
| 108 | 108 | if ($table instanceof Select) { |
| 109 | 109 | $this->table = $table->toSubquery(); |
| 110 | 110 | $this->alias = uniqid('_') . "_{$table->alias}"; |
| 111 | - } |
|
| 112 | - else { |
|
| 111 | + } else { |
|
| 113 | 112 | $this->table = (string)$table; |
| 114 | 113 | $this->alias = uniqid('_') . "__{$table}"; |
| 115 | 114 | } |
@@ -219,8 +218,7 @@ discard block |
||
| 219 | 218 | public function group (string $column) { |
| 220 | 219 | if (!strlen($this->_group)) { |
| 221 | 220 | $this->_group = " GROUP BY {$column}"; |
| 222 | - } |
|
| 223 | - else { |
|
| 221 | + } else { |
|
| 224 | 222 | $this->_group .= ", {$column}"; |
| 225 | 223 | } |
| 226 | 224 | return $this; |
@@ -235,8 +233,7 @@ discard block |
||
| 235 | 233 | public function having (string $condition) { |
| 236 | 234 | if (!strlen($this->_having)) { |
| 237 | 235 | $this->_having = " HAVING {$condition}"; |
| 238 | - } |
|
| 239 | - else { |
|
| 236 | + } else { |
|
| 240 | 237 | $this->_having .= " AND {$condition}"; |
| 241 | 238 | } |
| 242 | 239 | return $this; |
@@ -286,8 +283,7 @@ discard block |
||
| 286 | 283 | public function limit (int $limit, int $offset = 0) { |
| 287 | 284 | if ($limit == 0) { |
| 288 | 285 | $this->_limit = ''; |
| 289 | - } |
|
| 290 | - else { |
|
| 286 | + } else { |
|
| 291 | 287 | $this->_limit = " LIMIT {$limit}"; |
| 292 | 288 | if ($offset > 1) { |
| 293 | 289 | $this->_limit .= " OFFSET {$offset}"; |
@@ -366,8 +362,7 @@ discard block |
||
| 366 | 362 | } |
| 367 | 363 | if ($name === $alias) { |
| 368 | 364 | $_columns[] = "{$column}"; |
| 369 | - } |
|
| 370 | - else { |
|
| 365 | + } else { |
|
| 371 | 366 | $_columns[] = "{$column} AS {$alias}"; |
| 372 | 367 | } |
| 373 | 368 | $i++; |
@@ -419,8 +414,7 @@ discard block |
||
| 419 | 414 | public function where (string $condition) { |
| 420 | 415 | if (!strlen($this->_where)) { |
| 421 | 416 | $this->_where = " WHERE {$condition}"; |
| 422 | - } |
|
| 423 | - else { |
|
| 417 | + } else { |
|
| 424 | 418 | $this->_where .= " AND {$condition}"; |
| 425 | 419 | } |
| 426 | 420 | return $this; |
@@ -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 new Value($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 new Choice($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 | $driver = $this->db->getDriver(); |
| 58 | 58 | if ($arg instanceof Select) { |
| 59 | 59 | switch ($driver) { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param number|string $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 new Predicate("{$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': |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $multi `ALL|ANY` |
| 140 | 140 | * @return Predicate |
| 141 | 141 | */ |
| 142 | - public function isGreaterOrEqual ($arg, string $multi = 'ALL') { |
|
| 142 | + public function isGreaterOrEqual($arg, string $multi = 'ALL') { |
|
| 143 | 143 | if ($arg instanceof Select) { |
| 144 | 144 | switch ($this->db) { |
| 145 | 145 | case 'sqlite': |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $multi `ALL|ANY` |
| 170 | 170 | * @return Predicate |
| 171 | 171 | */ |
| 172 | - public function isLess ($arg, string $multi = 'ALL') { |
|
| 172 | + public function isLess($arg, string $multi = 'ALL') { |
|
| 173 | 173 | if ($arg instanceof Select) { |
| 174 | 174 | switch ($this->db) { |
| 175 | 175 | case 'sqlite': |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $multi `ALL|ANY` |
| 200 | 200 | * @return Predicate |
| 201 | 201 | */ |
| 202 | - public function isLessOrEqual ($arg, string $multi = 'ALL') { |
|
| 202 | + public function isLessOrEqual($arg, string $multi = 'ALL') { |
|
| 203 | 203 | if ($arg instanceof Select) { |
| 204 | 204 | switch ($this->db) { |
| 205 | 205 | case 'sqlite': |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @param string $pattern |
| 224 | 224 | * @return Predicate |
| 225 | 225 | */ |
| 226 | - public function isLike (string $pattern) { |
|
| 226 | + public function isLike(string $pattern) { |
|
| 227 | 227 | $pattern = $this->db->quote($pattern); |
| 228 | 228 | return new Predicate("{$this} LIKE {$pattern}"); |
| 229 | 229 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param null|bool|number|string|Select $arg |
| 235 | 235 | * @return Predicate |
| 236 | 236 | */ |
| 237 | - public function isNot ($arg) { |
|
| 237 | + public function isNot($arg) { |
|
| 238 | 238 | return $this->is($arg)->invert(); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param number|string $max |
| 246 | 246 | * @return Predicate |
| 247 | 247 | */ |
| 248 | - public function isNotBetween ($min, $max) { |
|
| 248 | + public function isNotBetween($min, $max) { |
|
| 249 | 249 | $min = $this->db->quote($min); |
| 250 | 250 | $max = $this->db->quote($max); |
| 251 | 251 | return new Predicate("{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @param bool|number|string|array|Select $arg |
| 258 | 258 | * @return Predicate |
| 259 | 259 | */ |
| 260 | - public function isNotEqual ($arg) { |
|
| 260 | + public function isNotEqual($arg) { |
|
| 261 | 261 | if ($arg instanceof Select) { |
| 262 | 262 | return new Predicate("{$this} NOT IN ({$arg->toSql()})"); |
| 263 | 263 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param string $pattern |
| 274 | 274 | * @return Predicate |
| 275 | 275 | */ |
| 276 | - public function isNotLike (string $pattern) { |
|
| 276 | + public function isNotLike(string $pattern) { |
|
| 277 | 277 | $pattern = $this->db->quote($pattern); |
| 278 | 278 | return new Predicate("{$this} NOT LIKE {$pattern}"); |
| 279 | 279 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param string $pattern |
| 285 | 285 | * @return Predicate |
| 286 | 286 | */ |
| 287 | - public function isNotRegExp (string $pattern) { |
|
| 287 | + public function isNotRegExp(string $pattern) { |
|
| 288 | 288 | $pattern = $this->db->quote($pattern); |
| 289 | 289 | return new Predicate("{$this} NOT REGEXP {$pattern}"); |
| 290 | 290 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param string $pattern |
| 296 | 296 | * @return Predicate |
| 297 | 297 | */ |
| 298 | - public function isRegExp (string $pattern) { |
|
| 298 | + public function isRegExp(string $pattern) { |
|
| 299 | 299 | $pattern = $this->db->quote($pattern); |
| 300 | 300 | return new Predicate("{$this} REGEXP {$pattern}"); |
| 301 | 301 | } |
@@ -66,8 +66,7 @@ |
||
| 66 | 66 | } |
| 67 | 67 | if ($arg === null or is_bool($arg)) { |
| 68 | 68 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
| 69 | - } |
|
| 70 | - else { |
|
| 69 | + } else { |
|
| 71 | 70 | $arg = $this->db->quote($arg); |
| 72 | 71 | } |
| 73 | 72 | $oper = ['mysql' => '<=>', 'sqlite' => 'IS'][$driver]; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param string[] $conditions |
| 18 | 18 | * @return Predicate |
| 19 | 19 | */ |
| 20 | - public static function all (array $conditions) { |
|
| 20 | + public static function all(array $conditions) { |
|
| 21 | 21 | if (count($conditions) === 1) { |
| 22 | 22 | return reset($conditions); |
| 23 | 23 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string[] $conditions |
| 31 | 31 | * @return Predicate |
| 32 | 32 | */ |
| 33 | - public static function any (array $conditions) { |
|
| 33 | + public static function any(array $conditions) { |
|
| 34 | 34 | if (count($conditions) === 1) { |
| 35 | 35 | return reset($conditions); |
| 36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return Predicate |
| 44 | 44 | */ |
| 45 | - public function invert () { |
|
| 45 | + public function invert() { |
|
| 46 | 46 | return new static("NOT({$this})"); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -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 | asort($columns); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - final public function __toString () { |
|
| 56 | + final public function __toString() { |
|
| 57 | 57 | return $this->name; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param array $values |
| 64 | 64 | * @return int Rows affected. |
| 65 | 65 | */ |
| 66 | - public function apply (array $values): int { |
|
| 66 | + public function apply(array $values): int { |
|
| 67 | 67 | $columns = implode(',', array_keys($values)); |
| 68 | 68 | $values = $this->db->quoteList($values); |
| 69 | 69 | switch ($this->db) { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param Closure $prepare `():Statement` |
| 86 | 86 | * @return Statement |
| 87 | 87 | */ |
| 88 | - protected function cache (string $key, Closure $prepare) { |
|
| 88 | + protected function cache(string $key, Closure $prepare) { |
|
| 89 | 89 | return $this->_cache[$key] ?? $this->_cache[$key] = $prepare->__invoke(); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param array $match `[a => b]` |
| 94 | 94 | * @return int |
| 95 | 95 | */ |
| 96 | - public function count (array $match = []) { |
|
| 96 | + public function count(array $match = []) { |
|
| 97 | 97 | $select = $this->select(['COUNT(*)']); |
| 98 | 98 | foreach ($match as $a => $b) { |
| 99 | 99 | $select->where($this->db->match($this[$a] ?? $a, $b)); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param array $match |
| 110 | 110 | * @return int Rows affected. |
| 111 | 111 | */ |
| 112 | - public function delete (array $match): int { |
|
| 112 | + public function delete(array $match): int { |
|
| 113 | 113 | foreach ($match as $a => $b) { |
| 114 | 114 | $match[$a] = $this->db->match($this[$a] ?? $a, $b); |
| 115 | 115 | } |
@@ -120,14 +120,14 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @return Column[] |
| 122 | 122 | */ |
| 123 | - final public function getColumns (): array { |
|
| 123 | + final public function getColumns(): array { |
|
| 124 | 124 | return $this->columns; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | - final public function getName (): string { |
|
| 130 | + final public function getName(): string { |
|
| 131 | 131 | return $this->name; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param array $values |
| 138 | 138 | * @return Statement |
| 139 | 139 | */ |
| 140 | - public function insert (array $values) { |
|
| 140 | + public function insert(array $values) { |
|
| 141 | 141 | $columns = implode(',', array_keys($values)); |
| 142 | 142 | $values = $this->db->quoteList($values); |
| 143 | 143 | return $this->db->query("INSERT INTO {$this} ($columns) VALUES ($values)"); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $name |
| 148 | 148 | * @return bool |
| 149 | 149 | */ |
| 150 | - public function offsetExists ($name): bool { |
|
| 150 | + public function offsetExists($name): bool { |
|
| 151 | 151 | return isset($this->columns[$name]); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param string $name |
| 156 | 156 | * @return Column |
| 157 | 157 | */ |
| 158 | - public function offsetGet ($name) { |
|
| 158 | + public function offsetGet($name) { |
|
| 159 | 159 | return $this->columns[$name]; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string[] $columns Defaults to all columns. |
| 166 | 166 | * @return Select |
| 167 | 167 | */ |
| 168 | - public function select (array $columns = []) { |
|
| 168 | + public function select(array $columns = []) { |
|
| 169 | 169 | if (empty($columns)) { |
| 170 | 170 | $columns = $this->columns; |
| 171 | 171 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param string $name |
| 179 | 179 | * @return Table |
| 180 | 180 | */ |
| 181 | - public function setName (string $name) { |
|
| 181 | + public function setName(string $name) { |
|
| 182 | 182 | $clone = clone $this; |
| 183 | 183 | $clone->name = $name; |
| 184 | 184 | foreach ($this->columns as $name => $column) { |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param array $match |
| 197 | 197 | * @return int Rows affected. |
| 198 | 198 | */ |
| 199 | - public function update (array $values, array $match): int { |
|
| 199 | + public function update(array $values, array $match): int { |
|
| 200 | 200 | foreach ($this->db->quoteArray($values) as $key => $value) { |
| 201 | 201 | $values[$key] = "{$key} = {$value}"; |
| 202 | 202 | } |