@@ -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 | } |
@@ -85,8 +85,10 @@ |
||
| 85 | 85 | * @param string|ValueInterface $else |
| 86 | 86 | * @return $this |
| 87 | 87 | */ |
| 88 | - public function else ($else) { |
|
| 88 | + public function else { |
|
| 89 | + ($else) { |
|
| 89 | 90 | $this->else = isset($else) ? $this->db->quote($else) : null; |
| 91 | + } |
|
| 90 | 92 | return $this; |
| 91 | 93 | } |
| 92 | 94 | |
@@ -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 | } |