@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * @return int |
12 | 12 | */ |
13 | - public function getId (); |
|
13 | + public function getId(); |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param DB $db |
23 | 23 | */ |
24 | - protected function __construct (DB $db) { |
|
24 | + protected function __construct(DB $db) { |
|
25 | 25 | $this->db = $db; |
26 | 26 | } |
27 | 27 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param array $args |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function __invoke (array $args = null) { |
|
34 | + public function __invoke(array $args = null) { |
|
35 | 35 | $this->execute($args); |
36 | 36 | return $this; |
37 | 37 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function __toString () { |
|
44 | + public function __toString() { |
|
45 | 45 | return $this->queryString; |
46 | 46 | } |
47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return bool |
55 | 55 | * @throws ArgumentCountError |
56 | 56 | */ |
57 | - public function execute ($args = null) { |
|
57 | + public function execute($args = null) { |
|
58 | 58 | $this->db->getLogger()->__invoke($this->queryString); |
59 | 59 | if ($result = !parent::execute($args)) { |
60 | 60 | $info = $this->errorInfo(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return int |
73 | 73 | */ |
74 | - public function getId (): int { |
|
74 | + public function getId(): int { |
|
75 | 75 | return (int)$this->db->lastInsertId(); |
76 | 76 | } |
77 | 77 | } |
@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public function __toString (); |
|
13 | + public function __toString(); |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -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 | } |
@@ -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()) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return Predicate |
26 | 26 | * @internal |
27 | 27 | */ |
28 | - protected function _isRelational ($arg, string $oper, string $multi) { |
|
28 | + protected function _isRelational($arg, string $oper, string $multi) { |
|
29 | 29 | static $inverse = [ |
30 | 30 | '<' => '>=', |
31 | 31 | '<=' => '>', |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param null|scalar|Select $arg |
55 | 55 | * @return Predicate |
56 | 56 | */ |
57 | - public function is ($arg): Predicate { |
|
57 | + public function is($arg): Predicate { |
|
58 | 58 | if ($arg instanceof Select) { |
59 | 59 | if ($this->db->isSQLite()) { |
60 | 60 | return Select::factory($this->db, $arg, [$arg[0]]) |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param number $max |
83 | 83 | * @return Predicate |
84 | 84 | */ |
85 | - public function isBetween ($min, $max) { |
|
85 | + public function isBetween($min, $max) { |
|
86 | 86 | $min = $this->db->quote($min); |
87 | 87 | $max = $this->db->quote($max); |
88 | 88 | return Predicate::factory($this->db, "{$this} BETWEEN {$min} AND {$max}"); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param scalar|array|Select $arg |
95 | 95 | * @return Predicate |
96 | 96 | */ |
97 | - public function isEqual ($arg) { |
|
97 | + public function isEqual($arg) { |
|
98 | 98 | return $this->db->match($this, $arg); |
99 | 99 | } |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return Predicate |
105 | 105 | */ |
106 | - public function isFalse () { |
|
106 | + public function isFalse() { |
|
107 | 107 | return Predicate::factory($this->db, "{$this} IS FALSE"); |
108 | 108 | } |
109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param number|string|Select $arg |
114 | 114 | * @return Predicate |
115 | 115 | */ |
116 | - public function isGt ($arg) { |
|
116 | + public function isGt($arg) { |
|
117 | 117 | return $this->_isRelational($arg, '>', 'ALL'); |
118 | 118 | } |
119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param Select $select |
124 | 124 | * @return Predicate |
125 | 125 | */ |
126 | - public function isGtAny (Select $select) { |
|
126 | + public function isGtAny(Select $select) { |
|
127 | 127 | return $this->_isRelational($select, '>', 'ANY'); |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param number|string|Select $arg |
134 | 134 | * @return Predicate |
135 | 135 | */ |
136 | - public function isGte ($arg) { |
|
136 | + public function isGte($arg) { |
|
137 | 137 | return $this->_isRelational($arg, '>=', 'ALL'); |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param Select $select |
144 | 144 | * @return Predicate |
145 | 145 | */ |
146 | - public function isGteAny (Select $select) { |
|
146 | + public function isGteAny(Select $select) { |
|
147 | 147 | return $this->_isRelational($select, '>=', 'ANY'); |
148 | 148 | } |
149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $pattern |
154 | 154 | * @return Predicate |
155 | 155 | */ |
156 | - public function isLike (string $pattern) { |
|
156 | + public function isLike(string $pattern) { |
|
157 | 157 | $pattern = $this->db->quote($pattern); |
158 | 158 | return Predicate::factory($this->db, "{$this} LIKE {$pattern}"); |
159 | 159 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param number|string|Select $arg |
165 | 165 | * @return Predicate |
166 | 166 | */ |
167 | - public function isLt ($arg) { |
|
167 | + public function isLt($arg) { |
|
168 | 168 | return $this->_isRelational($arg, '<', 'ALL'); |
169 | 169 | } |
170 | 170 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param Select $select |
175 | 175 | * @return Predicate |
176 | 176 | */ |
177 | - public function isLtAny (Select $select) { |
|
177 | + public function isLtAny(Select $select) { |
|
178 | 178 | return $this->_isRelational($select, '<', 'ANY'); |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param number|string|Select $arg |
185 | 185 | * @return Predicate |
186 | 186 | */ |
187 | - public function isLte ($arg) { |
|
187 | + public function isLte($arg) { |
|
188 | 188 | return $this->_isRelational($arg, '<=', 'ALL'); |
189 | 189 | } |
190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param Select $select |
195 | 195 | * @return Predicate |
196 | 196 | */ |
197 | - public function isLteAny (Select $select) { |
|
197 | + public function isLteAny(Select $select) { |
|
198 | 198 | return $this->_isRelational($select, '<=', 'ANY'); |
199 | 199 | } |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param null|scalar|Select $arg |
205 | 205 | * @return Predicate |
206 | 206 | */ |
207 | - public function isNot ($arg) { |
|
207 | + public function isNot($arg) { |
|
208 | 208 | return $this->is($arg)->not(); |
209 | 209 | } |
210 | 210 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param number $max |
216 | 216 | * @return Predicate |
217 | 217 | */ |
218 | - public function isNotBetween ($min, $max) { |
|
218 | + public function isNotBetween($min, $max) { |
|
219 | 219 | $min = $this->db->quote($min); |
220 | 220 | $max = $this->db->quote($max); |
221 | 221 | return Predicate::factory($this->db, "{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param scalar|array|Select $arg |
228 | 228 | * @return Predicate |
229 | 229 | */ |
230 | - public function isNotEqual ($arg) { |
|
230 | + public function isNotEqual($arg) { |
|
231 | 231 | if ($arg instanceof Select) { |
232 | 232 | return Predicate::factory($this->db, "{$this} NOT IN ({$arg->toSql()})"); |
233 | 233 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param string $pattern |
244 | 244 | * @return Predicate |
245 | 245 | */ |
246 | - public function isNotLike (string $pattern) { |
|
246 | + public function isNotLike(string $pattern) { |
|
247 | 247 | $pattern = $this->db->quote($pattern); |
248 | 248 | return Predicate::factory($this->db, "{$this} NOT LIKE {$pattern}"); |
249 | 249 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return Predicate |
255 | 255 | */ |
256 | - public function isNotNull () { |
|
256 | + public function isNotNull() { |
|
257 | 257 | return Predicate::factory($this->db, "{$this} IS NOT NULL"); |
258 | 258 | } |
259 | 259 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param string $pattern |
264 | 264 | * @return Predicate |
265 | 265 | */ |
266 | - public function isNotRegExp (string $pattern) { |
|
266 | + public function isNotRegExp(string $pattern) { |
|
267 | 267 | $pattern = $this->db->quote($pattern); |
268 | 268 | return Predicate::factory($this->db, "{$this} NOT REGEXP {$pattern}"); |
269 | 269 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return Predicate |
275 | 275 | */ |
276 | - public function isNull () { |
|
276 | + public function isNull() { |
|
277 | 277 | return Predicate::factory($this->db, "{$this} IS NULL"); |
278 | 278 | } |
279 | 279 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param string $pattern |
284 | 284 | * @return Predicate |
285 | 285 | */ |
286 | - public function isRegExp (string $pattern) { |
|
286 | + public function isRegExp(string $pattern) { |
|
287 | 287 | $pattern = $this->db->quote($pattern); |
288 | 288 | return Predicate::factory($this->db, "{$this} REGEXP {$pattern}"); |
289 | 289 | } |
@@ -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 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param null|string $subject |
60 | 60 | * @param array $values `[when => then]` for the subject. |
61 | 61 | */ |
62 | - public function __construct (DB $db, string $subject = null, array $values = []) { |
|
62 | + public function __construct(DB $db, string $subject = null, array $values = []) { |
|
63 | 63 | parent::__construct($db, ''); |
64 | 64 | $this->subject = $subject; |
65 | 65 | $this->whenValues($values); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function __toString (): string { |
|
71 | + public function __toString(): string { |
|
72 | 72 | $sql = 'CASE'; |
73 | 73 | if (isset($this->subject)) { |
74 | 74 | $sql .= " {$this->subject}"; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param string|ValueInterface $then |
100 | 100 | * @return $this |
101 | 101 | */ |
102 | - public function when ($expression, $then) { |
|
102 | + public function when($expression, $then) { |
|
103 | 103 | $this->values[$this->db->quote($expression)] = $this->db->quote($then); |
104 | 104 | return $this; |
105 | 105 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param array $values `[when => then]` |
114 | 114 | * @return $this |
115 | 115 | */ |
116 | - public function whenValues (array $values) { |
|
116 | + public function whenValues(array $values) { |
|
117 | 117 | foreach ($values as $when => $then) { |
118 | 118 | $this->when($when, $then); |
119 | 119 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @return static |
14 | 14 | */ |
15 | - public function not () { |
|
15 | + public function not() { |
|
16 | 16 | return static::factory($this->db, "NOT({$this})"); |
17 | 17 | } |
18 | 18 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param DB $db |
29 | 29 | * @param string $expression |
30 | 30 | */ |
31 | - public function __construct (DB $db, string $expression) { |
|
31 | + public function __construct(DB $db, string $expression) { |
|
32 | 32 | $this->db = $db; |
33 | 33 | $this->expression = $expression; |
34 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - public function __toString () { |
|
39 | + public function __toString() { |
|
40 | 40 | return $this->expression; |
41 | 41 | } |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @param array $args The first argument must be a {@link DB} instance. |
18 | 18 | * @return static |
19 | 19 | */ |
20 | - public static function __callStatic (string $ignored, array $args) { |
|
20 | + public static function __callStatic(string $ignored, array $args) { |
|
21 | 21 | /** @var DB $db */ |
22 | 22 | $db = $args[0]; |
23 | 23 | unset($args[0]); |