@@ -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 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | * |
| 13 | 13 | * @return Predicate |
| 14 | 14 | */ |
| 15 | - public function not () { |
|
| 15 | + public function not() { |
|
| 16 | 16 | return new static("NOT({$this})"); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $subject |
| 58 | 58 | * @param array $values `[when => then]` for the subject. |
| 59 | 59 | */ |
| 60 | - public function __construct (DB $db, string $subject = null, array $values = []) { |
|
| 60 | + public function __construct(DB $db, string $subject = null, array $values = []) { |
|
| 61 | 61 | parent::__construct($db, ''); |
| 62 | 62 | $this->subject = $subject; |
| 63 | 63 | $this->whenValues($values); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | - public function __toString () { |
|
| 69 | + public function __toString() { |
|
| 70 | 70 | $sql = 'CASE'; |
| 71 | 71 | if (isset($this->subject)) { |
| 72 | 72 | $sql .= " {$this->subject}"; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string|ValueInterface $then |
| 98 | 98 | * @return $this |
| 99 | 99 | */ |
| 100 | - public function when ($expression, $then) { |
|
| 100 | + public function when($expression, $then) { |
|
| 101 | 101 | $this->values[$this->db->quote($expression)] = $this->db->quote($then); |
| 102 | 102 | return $this; |
| 103 | 103 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param array $values `[when => then]` |
| 112 | 112 | * @return $this |
| 113 | 113 | */ |
| 114 | - public function whenValues (array $values) { |
|
| 114 | + public function whenValues(array $values) { |
|
| 115 | 115 | foreach ($values as $when => $then) { |
| 116 | 116 | $this->when($when, $then); |
| 117 | 117 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param array $values |
| 27 | 27 | * @return Value |
| 28 | 28 | */ |
| 29 | - public function coalesce (array $values) { |
|
| 29 | + public function coalesce(array $values) { |
|
| 30 | 30 | array_unshift($values, $this); |
| 31 | 31 | $values = $this->db->quoteList($values); |
| 32 | 32 | return $this->db->factory(Value::class, $this->db, "COALESCE({$values})"); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param null|bool|number|string|Select $arg |
| 42 | 42 | * @return Predicate |
| 43 | 43 | */ |
| 44 | - public function is ($arg): Predicate { |
|
| 44 | + public function is($arg): Predicate { |
|
| 45 | 45 | if ($arg instanceof Select) { |
| 46 | 46 | if ($this->db->isSQLite()) { |
| 47 | 47 | /** @var Select $sub */ |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param number $max |
| 70 | 70 | * @return Predicate |
| 71 | 71 | */ |
| 72 | - public function isBetween ($min, $max) { |
|
| 72 | + public function isBetween($min, $max) { |
|
| 73 | 73 | $min = $this->db->quote($min); |
| 74 | 74 | $max = $this->db->quote($max); |
| 75 | 75 | return $this->db->factory(Predicate::class, "{$this} BETWEEN {$min} AND {$max}"); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param bool|number|string|array|Select $arg |
| 82 | 82 | * @return Predicate |
| 83 | 83 | */ |
| 84 | - public function isEqual ($arg) { |
|
| 84 | + public function isEqual($arg) { |
|
| 85 | 85 | return $this->db->match($this, $arg); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return Predicate |
| 92 | 92 | */ |
| 93 | - public function isFalse () { |
|
| 93 | + public function isFalse() { |
|
| 94 | 94 | return $this->db->factory(Predicate::class, "{$this} IS FALSE"); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param string $multi `ALL|ANY` |
| 107 | 107 | * @return Predicate |
| 108 | 108 | */ |
| 109 | - public function isGreater ($arg, string $multi = 'ALL') { |
|
| 109 | + public function isGreater($arg, string $multi = 'ALL') { |
|
| 110 | 110 | if ($arg instanceof Select) { |
| 111 | 111 | switch ($this->db) { |
| 112 | 112 | case 'sqlite': |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $multi `ALL|ANY` |
| 138 | 138 | * @return Predicate |
| 139 | 139 | */ |
| 140 | - public function isGreaterOrEqual ($arg, string $multi = 'ALL') { |
|
| 140 | + public function isGreaterOrEqual($arg, string $multi = 'ALL') { |
|
| 141 | 141 | if ($arg instanceof Select) { |
| 142 | 142 | switch ($this->db) { |
| 143 | 143 | case 'sqlite': |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param string $multi `ALL|ANY` |
| 169 | 169 | * @return Predicate |
| 170 | 170 | */ |
| 171 | - public function isLess ($arg, string $multi = 'ALL') { |
|
| 171 | + public function isLess($arg, string $multi = 'ALL') { |
|
| 172 | 172 | if ($arg instanceof Select) { |
| 173 | 173 | switch ($this->db) { |
| 174 | 174 | 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': |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @param string $pattern |
| 225 | 225 | * @return Predicate |
| 226 | 226 | */ |
| 227 | - public function isLike (string $pattern) { |
|
| 227 | + public function isLike(string $pattern) { |
|
| 228 | 228 | $pattern = $this->db->quote($pattern); |
| 229 | 229 | return $this->db->factory(Predicate::class, "{$this} LIKE {$pattern}"); |
| 230 | 230 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param null|bool|number|string|Select $arg |
| 236 | 236 | * @return Predicate |
| 237 | 237 | */ |
| 238 | - public function isNot ($arg) { |
|
| 238 | + public function isNot($arg) { |
|
| 239 | 239 | return $this->is($arg)->not(); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @param number $max |
| 247 | 247 | * @return Predicate |
| 248 | 248 | */ |
| 249 | - public function isNotBetween ($min, $max) { |
|
| 249 | + public function isNotBetween($min, $max) { |
|
| 250 | 250 | $min = $this->db->quote($min); |
| 251 | 251 | $max = $this->db->quote($max); |
| 252 | 252 | return $this->db->factory(Predicate::class, "{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @param bool|number|string|array|Select $arg |
| 259 | 259 | * @return Predicate |
| 260 | 260 | */ |
| 261 | - public function isNotEqual ($arg) { |
|
| 261 | + public function isNotEqual($arg) { |
|
| 262 | 262 | if ($arg instanceof Select) { |
| 263 | 263 | return $this->db->factory(Predicate::class, "{$this} NOT IN ({$arg->toSql()})"); |
| 264 | 264 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @param string $pattern |
| 275 | 275 | * @return Predicate |
| 276 | 276 | */ |
| 277 | - public function isNotLike (string $pattern) { |
|
| 277 | + public function isNotLike(string $pattern) { |
|
| 278 | 278 | $pattern = $this->db->quote($pattern); |
| 279 | 279 | return $this->db->factory(Predicate::class, "{$this} NOT LIKE {$pattern}"); |
| 280 | 280 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @return Predicate |
| 286 | 286 | */ |
| 287 | - public function isNotNull () { |
|
| 287 | + public function isNotNull() { |
|
| 288 | 288 | return $this->db->factory(Predicate::class, "{$this} IS NOT NULL"); |
| 289 | 289 | } |
| 290 | 290 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @param string $pattern |
| 295 | 295 | * @return Predicate |
| 296 | 296 | */ |
| 297 | - public function isNotRegExp (string $pattern) { |
|
| 297 | + public function isNotRegExp(string $pattern) { |
|
| 298 | 298 | $pattern = $this->db->quote($pattern); |
| 299 | 299 | return $this->db->factory(Predicate::class, "{$this} NOT REGEXP {$pattern}"); |
| 300 | 300 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @return Predicate |
| 306 | 306 | */ |
| 307 | - public function isNull () { |
|
| 307 | + public function isNull() { |
|
| 308 | 308 | return $this->db->factory(Predicate::class, "{$this} IS NULL"); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @param string $pattern |
| 315 | 315 | * @return Predicate |
| 316 | 316 | */ |
| 317 | - public function isRegExp (string $pattern) { |
|
| 317 | + public function isRegExp(string $pattern) { |
|
| 318 | 318 | $pattern = $this->db->quote($pattern); |
| 319 | 319 | return $this->db->factory(Predicate::class, "{$this} REGEXP {$pattern}"); |
| 320 | 320 | } |