@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param string|Select $table |
75 | 75 | * @param string[] $columns |
76 | 76 | */ |
77 | - public function __construct (DB $db, $table, array $columns) { |
|
77 | + public function __construct(DB $db, $table, array $columns) { |
|
78 | 78 | parent::__construct($db); |
79 | 79 | if ($table instanceof Select) { |
80 | 80 | $table = $table->toSubquery(); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Gives the clone a new alias. |
98 | 98 | */ |
99 | - public function __clone () { |
|
99 | + public function __clone() { |
|
100 | 100 | $this->alias = uniqid('_') . "__{$this->table}"; |
101 | 101 | } |
102 | 102 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param array $args |
105 | 105 | * @return Statement |
106 | 106 | */ |
107 | - public function __invoke (array $args = []) { |
|
107 | + public function __invoke(array $args = []) { |
|
108 | 108 | return $this->execute($args); |
109 | 109 | } |
110 | 110 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - final public function __toString () { |
|
116 | + final public function __toString() { |
|
117 | 117 | return $this->alias; |
118 | 118 | } |
119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param array $args Execution arguments. |
124 | 124 | * @return int |
125 | 125 | */ |
126 | - public function count (array $args = []): int { |
|
126 | + public function count(array $args = []): int { |
|
127 | 127 | $clone = clone $this; |
128 | 128 | $clone->_columns = 'COUNT(*)'; |
129 | 129 | return (int)$clone->execute($args)->fetchColumn(); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param array $args |
136 | 136 | * @return Statement |
137 | 137 | */ |
138 | - public function execute (array $args = []) { |
|
138 | + public function execute(array $args = []) { |
|
139 | 139 | if (empty($args)) { |
140 | 140 | return $this->db->query($this->toSql()); |
141 | 141 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param array $args Execution arguments. |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public function fetchAll (array $args = []): array { |
|
153 | + public function fetchAll(array $args = []): array { |
|
154 | 154 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
155 | 155 | } |
156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param array $args Execution arguments. |
164 | 164 | * @return Generator |
165 | 165 | */ |
166 | - public function fetchEach (array $args = []) { |
|
166 | + public function fetchEach(array $args = []) { |
|
167 | 167 | yield from $this->fetcher->__invoke($this->execute($args)); |
168 | 168 | } |
169 | 169 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return Generator |
176 | 176 | */ |
177 | - public function getIterator () { |
|
177 | + public function getIterator() { |
|
178 | 178 | yield from $this->fetchEach(); |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param string $column |
185 | 185 | * @return $this |
186 | 186 | */ |
187 | - public function group (string $column) { |
|
187 | + public function group(string $column) { |
|
188 | 188 | if (!strlen($this->_group)) { |
189 | 189 | $this->_group = " GROUP BY {$column}"; |
190 | 190 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param string $condition |
201 | 201 | * @return $this |
202 | 202 | */ |
203 | - public function having (string $condition) { |
|
203 | + public function having(string $condition) { |
|
204 | 204 | if (!strlen($this->_having)) { |
205 | 205 | $this->_having = " HAVING {$condition}"; |
206 | 206 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return Predicate |
217 | 217 | */ |
218 | - public function isCorrelated () { |
|
218 | + public function isCorrelated() { |
|
219 | 219 | return new Predicate("EXISTS ({$this->toSql()})"); |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return Predicate |
226 | 226 | */ |
227 | - public function isNotCorrelated () { |
|
227 | + public function isNotCorrelated() { |
|
228 | 228 | return new Predicate("NOT EXISTS ({$this->toSql()}"); |
229 | 229 | } |
230 | 230 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param string $type |
237 | 237 | * @return $this |
238 | 238 | */ |
239 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
239 | + public function join($table, string $condition, string $type = 'INNER') { |
|
240 | 240 | if ($table instanceof Select) { |
241 | 241 | $table = $table->toSubquery(); |
242 | 242 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param int $offset |
252 | 252 | * @return $this |
253 | 253 | */ |
254 | - public function limit (int $limit, int $offset = 0) { |
|
254 | + public function limit(int $limit, int $offset = 0) { |
|
255 | 255 | if ($limit == 0) { |
256 | 256 | $this->_limit = ''; |
257 | 257 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param string $name Name or alias if used. |
271 | 271 | * @return bool |
272 | 272 | */ |
273 | - public function offsetExists ($name): bool { |
|
273 | + public function offsetExists($name): bool { |
|
274 | 274 | return true; |
275 | 275 | } |
276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param string $name Name, or alias if used. |
281 | 281 | * @return Column |
282 | 282 | */ |
283 | - public function offsetGet ($name) { |
|
283 | + public function offsetGet($name) { |
|
284 | 284 | return new Column($this->db, $name, $this->alias); |
285 | 285 | } |
286 | 286 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param string $order |
291 | 291 | * @return $this |
292 | 292 | */ |
293 | - public function order (string $order) { |
|
293 | + public function order(string $order) { |
|
294 | 294 | if (strlen($order)) { |
295 | 295 | $order = " ORDER BY {$order}"; |
296 | 296 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** |
302 | 302 | * @return Statement |
303 | 303 | */ |
304 | - public function prepare () { |
|
304 | + public function prepare() { |
|
305 | 305 | return $this->db->prepare($this->toSql()); |
306 | 306 | } |
307 | 307 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param Closure $fetcher |
310 | 310 | * @return $this |
311 | 311 | */ |
312 | - public function setFetcher (Closure $fetcher) { |
|
312 | + public function setFetcher(Closure $fetcher) { |
|
313 | 313 | $this->fetcher = $fetcher; |
314 | 314 | return $this; |
315 | 315 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * @return string |
319 | 319 | */ |
320 | - public function toSql (): string { |
|
320 | + public function toSql(): string { |
|
321 | 321 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
322 | 322 | $sql .= $this->_join; |
323 | 323 | $sql .= $this->_where; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @return string |
335 | 335 | */ |
336 | - public function toSubquery (): string { |
|
336 | + public function toSubquery(): string { |
|
337 | 337 | return "({$this->toSql()}) AS {$this->alias}"; |
338 | 338 | } |
339 | 339 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param string $condition |
344 | 344 | * @return $this |
345 | 345 | */ |
346 | - public function where (string $condition) { |
|
346 | + public function where(string $condition) { |
|
347 | 347 | if (!strlen($this->_where)) { |
348 | 348 | $this->_where = " WHERE {$condition}"; |
349 | 349 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param array $values |
24 | 24 | * @return Value |
25 | 25 | */ |
26 | - public function coalesce (array $values) { |
|
26 | + public function coalesce(array $values) { |
|
27 | 27 | array_unshift($values, $this); |
28 | 28 | $values = implode(',', $this->db->quoteArray($values)); |
29 | 29 | return new Value($this->db, "COALESCE({$values})"); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param string[] $values `[when => then]` |
36 | 36 | * @return Choice |
37 | 37 | */ |
38 | - public function getChoice (array $values) { |
|
38 | + public function getChoice(array $values) { |
|
39 | 39 | return new Choice($this->db, $this, $values); |
40 | 40 | } |
41 | 41 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param null|bool|string|Select $arg |
49 | 49 | * @return Predicate |
50 | 50 | */ |
51 | - public function is ($arg): Predicate { |
|
51 | + public function is($arg): Predicate { |
|
52 | 52 | if ($arg === null or is_bool($arg)) { |
53 | 53 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
54 | 54 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param number|string $max |
67 | 67 | * @return Predicate |
68 | 68 | */ |
69 | - public function isBetween ($min, $max) { |
|
69 | + public function isBetween($min, $max) { |
|
70 | 70 | return new Predicate("{$this} BETWEEN {$this->db->quote($min)} AND {$this->db->quote($max)}"); |
71 | 71 | } |
72 | 72 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string|array|Select $arg |
77 | 77 | * @return Predicate |
78 | 78 | */ |
79 | - public function isEqual ($arg) { |
|
79 | + public function isEqual($arg) { |
|
80 | 80 | return Predicate::compare($this, $this->db->quoteMixed($arg)); |
81 | 81 | } |
82 | 82 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param string|Select $arg |
87 | 87 | * @return Predicate |
88 | 88 | */ |
89 | - public function isGreater ($arg) { |
|
89 | + public function isGreater($arg) { |
|
90 | 90 | return Predicate::compare($this, $this->db->quote($arg), '>', 'ALL'); |
91 | 91 | } |
92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param string|Select $arg |
97 | 97 | * @return Predicate |
98 | 98 | */ |
99 | - public function isGreaterOrEqual ($arg) { |
|
99 | + public function isGreaterOrEqual($arg) { |
|
100 | 100 | return Predicate::compare($this, $this->db->quote($arg), '>=', 'ALL'); |
101 | 101 | } |
102 | 102 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string|Select $arg |
107 | 107 | * @return Predicate |
108 | 108 | */ |
109 | - public function isLess ($arg) { |
|
109 | + public function isLess($arg) { |
|
110 | 110 | return Predicate::compare($this, $this->db->quote($arg), '<', 'ALL'); |
111 | 111 | } |
112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string|Select $arg |
117 | 117 | * @return Predicate |
118 | 118 | */ |
119 | - public function isLessOrEqual ($arg) { |
|
119 | + public function isLessOrEqual($arg) { |
|
120 | 120 | return Predicate::compare($this, $this->db->quote($arg), '<=', 'ALL'); |
121 | 121 | } |
122 | 122 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $pattern |
127 | 127 | * @return Predicate |
128 | 128 | */ |
129 | - public function isLike (string $pattern) { |
|
129 | + public function isLike(string $pattern) { |
|
130 | 130 | return Predicate::compare($this, $this->db->quote($pattern), 'LIKE'); |
131 | 131 | } |
132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param null|bool|string|Select $arg |
137 | 137 | * @return Predicate |
138 | 138 | */ |
139 | - public function isNot ($arg) { |
|
139 | + public function isNot($arg) { |
|
140 | 140 | return $this->is($arg)->invert(); |
141 | 141 | } |
142 | 142 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param number|string $max |
148 | 148 | * @return Predicate |
149 | 149 | */ |
150 | - public function isNotBetween ($min, $max) { |
|
150 | + public function isNotBetween($min, $max) { |
|
151 | 151 | return new Predicate("{$this} NOT BETWEEN {$this->db->quote($min)} AND {$this->db->quote($max)}"); |
152 | 152 | } |
153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string|array|Select $arg |
158 | 158 | * @return Predicate |
159 | 159 | */ |
160 | - public function isNotEqual ($arg) { |
|
160 | + public function isNotEqual($arg) { |
|
161 | 161 | return Predicate::compare($this, $this->db->quoteMixed($arg), '<>', 'ALL', 'NOT IN'); |
162 | 162 | } |
163 | 163 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param string $pattern |
168 | 168 | * @return Predicate |
169 | 169 | */ |
170 | - public function isNotLike (string $pattern) { |
|
170 | + public function isNotLike(string $pattern) { |
|
171 | 171 | return Predicate::compare($this, $this->db->quote($pattern), 'NOT LIKE'); |
172 | 172 | } |
173 | 173 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string $pattern |
178 | 178 | * @return Predicate |
179 | 179 | */ |
180 | - public function isNotRegExp (string $pattern) { |
|
180 | + public function isNotRegExp(string $pattern) { |
|
181 | 181 | return Predicate::compare($this, $this->db->quote($pattern), 'NOT REGEXP'); |
182 | 182 | } |
183 | 183 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param string $pattern |
188 | 188 | * @return Predicate |
189 | 189 | */ |
190 | - public function isRegExp (string $pattern) { |
|
190 | + public function isRegExp(string $pattern) { |
|
191 | 191 | return Predicate::compare($this, $this->db->quote($pattern), 'REGEXP'); |
192 | 192 | } |
193 | 193 | } |
194 | 194 | \ No newline at end of file |
@@ -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 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string|ValueInterface $subject |
53 | 53 | * @param array $values `[when => then]` for the subject. |
54 | 54 | */ |
55 | - public function __construct (DB $db, $subject = null, array $values = []) { |
|
55 | + public function __construct(DB $db, $subject = null, array $values = []) { |
|
56 | 56 | parent::__construct($db, ''); |
57 | 57 | $this->subject = (string)$this->db->quote($subject); |
58 | 58 | $this->setValues($values); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - public function __toString () { |
|
64 | + public function __toString() { |
|
65 | 65 | $sql = 'CASE'; |
66 | 66 | if (strlen($this->subject)) { |
67 | 67 | $sql .= " {$this->subject}"; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string|ValueInterface |
81 | 81 | * @return $this |
82 | 82 | */ |
83 | - public function setElse ($else) { |
|
83 | + public function setElse($else) { |
|
84 | 84 | $this->else = (string)$this->db->quote($else); |
85 | 85 | return $this; |
86 | 86 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string|ValueInterface $then |
93 | 93 | * @return $this |
94 | 94 | */ |
95 | - public function setValue ($when, $then) { |
|
95 | + public function setValue($when, $then) { |
|
96 | 96 | $when = (string)$this->db->quote($when); |
97 | 97 | $then = (string)$this->db->quote($then); |
98 | 98 | $this->values[$when] = $then; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param array $values `[when => then]` |
106 | 106 | * @return $this |
107 | 107 | */ |
108 | - public function setValues (array $values) { |
|
108 | + public function setValues(array $values) { |
|
109 | 109 | foreach ($values as $when => $then) { |
110 | 110 | $this->setValue($when, $then); |
111 | 111 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return Numeric |
21 | 21 | */ |
22 | - public function abs () { |
|
22 | + public function abs() { |
|
23 | 23 | return new Numeric($this->db, "ABS({$this})"); |
24 | 24 | } |
25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param number|ValueInterface $arg |
30 | 30 | * @return Numeric |
31 | 31 | */ |
32 | - public function add ($arg) { |
|
32 | + public function add($arg) { |
|
33 | 33 | return new Numeric($this->db, "({$this} + {$arg})"); |
34 | 34 | } |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return Numeric |
40 | 40 | */ |
41 | - public function ceil () { |
|
41 | + public function ceil() { |
|
42 | 42 | return new Numeric($this->db, "CEIL({$this})"); |
43 | 43 | } |
44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param number|ValueInterface $arg |
49 | 49 | * @return Numeric |
50 | 50 | */ |
51 | - public function divide ($arg) { |
|
51 | + public function divide($arg) { |
|
52 | 52 | return new Numeric($this->db, "({$this} / {$arg})"); |
53 | 53 | } |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return Numeric |
59 | 59 | */ |
60 | - public function floor () { |
|
60 | + public function floor() { |
|
61 | 61 | return new Numeric($this->db, "FLOOR({$this})"); |
62 | 62 | } |
63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return Predicate |
68 | 68 | */ |
69 | - public function isEven () { |
|
69 | + public function isEven() { |
|
70 | 70 | return new Predicate("({$this} % 2) = 0"); |
71 | 71 | } |
72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return Predicate |
77 | 77 | */ |
78 | - public function isNegative () { |
|
78 | + public function isNegative() { |
|
79 | 79 | return new Predicate("{$this} < 0"); |
80 | 80 | } |
81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return Predicate |
86 | 86 | */ |
87 | - public function isOdd () { |
|
87 | + public function isOdd() { |
|
88 | 88 | return new Predicate("({$this} % 2) <> 0"); |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return Predicate |
95 | 95 | */ |
96 | - public function isPositive () { |
|
96 | + public function isPositive() { |
|
97 | 97 | return new Predicate("{$this} > 0"); |
98 | 98 | } |
99 | 99 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param number|ValueInterface $arg |
104 | 104 | * @return Numeric |
105 | 105 | */ |
106 | - public function modulo ($arg) { |
|
106 | + public function modulo($arg) { |
|
107 | 107 | return new Numeric($this->db, "({$this} % {$arg})"); |
108 | 108 | } |
109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param number|ValueInterface $arg |
114 | 114 | * @return Numeric |
115 | 115 | */ |
116 | - public function multiply ($arg) { |
|
116 | + public function multiply($arg) { |
|
117 | 117 | return new Numeric($this->db, "({$this} * {$arg})"); |
118 | 118 | } |
119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param number|ValueInterface $exponent |
124 | 124 | * @return Numeric |
125 | 125 | */ |
126 | - public function pow ($exponent) { |
|
126 | + public function pow($exponent) { |
|
127 | 127 | return new Numeric($this->db, "POW({$this},{$exponent})"); |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param int $decimals |
134 | 134 | * @return Numeric |
135 | 135 | */ |
136 | - public function round (int $decimals = 0) { |
|
136 | + public function round(int $decimals = 0) { |
|
137 | 137 | return new Numeric($this->db, "ROUND({$this},{$decimals})"); |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param number|ValueInterface $arg |
144 | 144 | * @return Numeric |
145 | 145 | */ |
146 | - public function subtract ($arg) { |
|
146 | + public function subtract($arg) { |
|
147 | 147 | return new Numeric($this->db, "({$this} - {$arg})"); |
148 | 148 | } |
149 | 149 | } |
150 | 150 | \ No newline at end of file |