@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return Num |
16 | 16 | */ |
17 | - public function abs () { |
|
17 | + public function abs() { |
|
18 | 18 | return Num::factory($this->db, "ABS({$this})"); |
19 | 19 | } |
20 | 20 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return Num |
25 | 25 | */ |
26 | - public function acos () { |
|
26 | + public function acos() { |
|
27 | 27 | return Num::factory($this->db, "ACOS({$this})"); |
28 | 28 | } |
29 | 29 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param number|ValueInterface $arg |
34 | 34 | * @return Num |
35 | 35 | */ |
36 | - public function add ($arg) { |
|
36 | + public function add($arg) { |
|
37 | 37 | $arg = $this->db->quote($arg); |
38 | 38 | return Num::factory($this->db, "({$this} + {$arg})"); |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return Num |
45 | 45 | */ |
46 | - public function asin () { |
|
46 | + public function asin() { |
|
47 | 47 | return Num::factory($this->db, "ASIN({$this})"); |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return Num |
54 | 54 | */ |
55 | - public function atan () { |
|
55 | + public function atan() { |
|
56 | 56 | return Num::factory($this->db, "ATAN({$this})"); |
57 | 57 | } |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return Num |
63 | 63 | */ |
64 | - public function ceil () { |
|
64 | + public function ceil() { |
|
65 | 65 | return Num::factory($this->db, "CEIL({$this})"); |
66 | 66 | } |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return Num |
72 | 72 | */ |
73 | - public function cos () { |
|
73 | + public function cos() { |
|
74 | 74 | return Num::factory($this->db, "COS({$this})"); |
75 | 75 | } |
76 | 76 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return Num |
83 | 83 | */ |
84 | - public function degrees () { |
|
84 | + public function degrees() { |
|
85 | 85 | return Num::factory($this->db, "DEGREES({$this})"); |
86 | 86 | } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param number|ValueInterface $arg |
92 | 92 | * @return Num |
93 | 93 | */ |
94 | - public function div ($arg) { |
|
94 | + public function div($arg) { |
|
95 | 95 | $arg = $this->db->quote($arg); |
96 | 96 | return Num::factory($this->db, "({$this} / {$arg})"); |
97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return Num |
105 | 105 | */ |
106 | - public function exp () { |
|
106 | + public function exp() { |
|
107 | 107 | return Num::factory($this->db, "EXP({$this})"); |
108 | 108 | } |
109 | 109 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return Num |
114 | 114 | */ |
115 | - public function floor () { |
|
115 | + public function floor() { |
|
116 | 116 | return Num::factory($this->db, "FLOOR({$this})"); |
117 | 117 | } |
118 | 118 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return Predicate |
123 | 123 | */ |
124 | - public function isEven () { |
|
124 | + public function isEven() { |
|
125 | 125 | return Predicate::factory($this->db, "({$this} % 2) = 0"); |
126 | 126 | } |
127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return Predicate |
132 | 132 | */ |
133 | - public function isNegative () { |
|
133 | + public function isNegative() { |
|
134 | 134 | return Predicate::factory($this->db, "{$this} < 0"); |
135 | 135 | } |
136 | 136 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return Predicate |
141 | 141 | */ |
142 | - public function isOdd () { |
|
142 | + public function isOdd() { |
|
143 | 143 | return Predicate::factory($this->db, "({$this} % 2) <> 0"); |
144 | 144 | } |
145 | 145 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return Predicate |
150 | 150 | */ |
151 | - public function isPositive () { |
|
151 | + public function isPositive() { |
|
152 | 152 | return Predicate::factory($this->db, "{$this} > 0"); |
153 | 153 | } |
154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return Num |
159 | 159 | */ |
160 | - public function ln () { |
|
160 | + public function ln() { |
|
161 | 161 | return Num::factory($this->db, "LN({$this})"); |
162 | 162 | } |
163 | 163 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param float $base |
170 | 170 | * @return Num |
171 | 171 | */ |
172 | - public function log (float $base) { |
|
172 | + public function log(float $base) { |
|
173 | 173 | return Num::factory($this->db, "LOG({$base},{$this})"); |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return Num |
180 | 180 | */ |
181 | - public function log10 () { |
|
181 | + public function log10() { |
|
182 | 182 | return Num::factory($this->db, "LOG10({$this})"); |
183 | 183 | } |
184 | 184 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return Num |
189 | 189 | */ |
190 | - public function log2 () { |
|
190 | + public function log2() { |
|
191 | 191 | return Num::factory($this->db, "LOG2({$this})"); |
192 | 192 | } |
193 | 193 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param float $divisor |
198 | 198 | * @return Num |
199 | 199 | */ |
200 | - public function mod (float $divisor) { |
|
200 | + public function mod(float $divisor) { |
|
201 | 201 | return Num::factory($this->db, "({$this} % {$divisor})"); |
202 | 202 | } |
203 | 203 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param number|ValueInterface $arg |
208 | 208 | * @return Num |
209 | 209 | */ |
210 | - public function mul ($arg) { |
|
210 | + public function mul($arg) { |
|
211 | 211 | $arg = $this->db->quote($arg); |
212 | 212 | return Num::factory($this->db, "({$this} * {$arg})"); |
213 | 213 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param float $exponent |
219 | 219 | * @return Num |
220 | 220 | */ |
221 | - public function pow (float $exponent) { |
|
221 | + public function pow(float $exponent) { |
|
222 | 222 | return Num::factory($this->db, "POW({$this},{$exponent})"); |
223 | 223 | } |
224 | 224 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return Num |
231 | 231 | */ |
232 | - public function radians () { |
|
232 | + public function radians() { |
|
233 | 233 | return Num::factory($this->db, "RADIANS({$this})"); |
234 | 234 | } |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param int $decimals |
240 | 240 | * @return Num |
241 | 241 | */ |
242 | - public function round (int $decimals = 0) { |
|
242 | + public function round(int $decimals = 0) { |
|
243 | 243 | return Num::factory($this->db, "ROUND({$this},{$decimals})"); |
244 | 244 | } |
245 | 245 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return Num `-1`, `0`, `1` |
250 | 250 | */ |
251 | - public function sign () { |
|
251 | + public function sign() { |
|
252 | 252 | return Num::factory($this->db, "SIGN({$this})"); |
253 | 253 | } |
254 | 254 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return Num |
259 | 259 | */ |
260 | - public function sin () { |
|
260 | + public function sin() { |
|
261 | 261 | return Num::factory($this->db, "SIN({$this})"); |
262 | 262 | } |
263 | 263 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return Num |
268 | 268 | */ |
269 | - public function sqrt () { |
|
269 | + public function sqrt() { |
|
270 | 270 | return Num::factory($this->db, "SQRT({$this})"); |
271 | 271 | } |
272 | 272 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param number|ValueInterface $arg |
277 | 277 | * @return Num |
278 | 278 | */ |
279 | - public function sub ($arg) { |
|
279 | + public function sub($arg) { |
|
280 | 280 | $arg = $this->db->quote($arg); |
281 | 281 | return Num::factory($this->db, "({$this} - {$arg})"); |
282 | 282 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return Num |
288 | 288 | */ |
289 | - public function tan () { |
|
289 | + public function tan() { |
|
290 | 290 | return Num::factory($this->db, "TAN({$this})"); |
291 | 291 | } |
292 | 292 | } |
293 | 293 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @param scalar[] $values |
13 | 13 | * @return Value |
14 | 14 | */ |
15 | - public function coalesce (array $values) { |
|
15 | + public function coalesce(array $values) { |
|
16 | 16 | array_unshift($values, $this); |
17 | 17 | $values = $this->db->quoteList($values); |
18 | 18 | return Value::factory($this->db, "COALESCE({$values})"); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param int $to |
26 | 26 | * @return Text |
27 | 27 | */ |
28 | - public function toBase (int $from, int $to) { |
|
28 | + public function toBase(int $from, int $to) { |
|
29 | 29 | return Text::factory($this->db, "CONV({$this},{$from},{$to})"); |
30 | 30 | } |
31 | 31 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param int $from |
36 | 36 | * @return Num |
37 | 37 | */ |
38 | - public function toBase10 (int $from) { |
|
38 | + public function toBase10(int $from) { |
|
39 | 39 | return Num::factory($this->db, "CONV({$this},{$from},10)"); |
40 | 40 | } |
41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param int $from |
48 | 48 | * @return Text |
49 | 49 | */ |
50 | - public function toBase16 (int $from) { |
|
50 | + public function toBase16(int $from) { |
|
51 | 51 | return $this->toBase($from, 16); |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param int $from |
58 | 58 | * @return Text |
59 | 59 | */ |
60 | - public function toBase2 (int $from) { |
|
60 | + public function toBase2(int $from) { |
|
61 | 61 | return $this->toBase($from, 2); |
62 | 62 | } |
63 | 63 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param int $from |
68 | 68 | * @return Text |
69 | 69 | */ |
70 | - public function toBase8 (int $from) { |
|
70 | + public function toBase8(int $from) { |
|
71 | 71 | return $this->toBase($from, 8); |
72 | 72 | } |
73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return Num |
78 | 78 | */ |
79 | - public function toFloat () { |
|
79 | + public function toFloat() { |
|
80 | 80 | if ($this->db->isSQLite()) { |
81 | 81 | return Num::factory($this->db, "CAST({$this} AS REAL)"); |
82 | 82 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return Num |
90 | 90 | */ |
91 | - public function toInt () { |
|
91 | + public function toInt() { |
|
92 | 92 | if ($this->db->isSQLite()) { |
93 | 93 | return Num::factory($this->db, "CAST({$this} AS INTEGER)"); |
94 | 94 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return Text |
102 | 102 | */ |
103 | - public function toText () { |
|
103 | + public function toText() { |
|
104 | 104 | if ($this->db->isSQLite()) { |
105 | 105 | return Text::factory($this->db, "CAST({$this} AS TEXT)"); |
106 | 106 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param DB $db |
35 | 35 | */ |
36 | - public function __construct (DB $db) { |
|
36 | + public function __construct(DB $db) { |
|
37 | 37 | $this->db = $db; |
38 | 38 | $db->beginTransaction(); |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Rolls back if the instance wasn't committed. |
43 | 43 | */ |
44 | - public function __destruct () { |
|
44 | + public function __destruct() { |
|
45 | 45 | if (!$this->committed) { |
46 | 46 | $this->db->rollBack(); |
47 | 47 | } |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return true |
56 | 56 | */ |
57 | - public function commit (): bool { |
|
57 | + public function commit(): bool { |
|
58 | 58 | return $this->committed or $this->committed = $this->db->commit(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return bool |
63 | 63 | */ |
64 | - final public function wasCommitted (): bool { |
|
64 | + final public function wasCommitted(): bool { |
|
65 | 65 | return $this->committed; |
66 | 66 | } |
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $name |
43 | 43 | * @param string[] $columns |
44 | 44 | */ |
45 | - public function __construct (DB $db, string $name, array $columns) { |
|
45 | + public function __construct(DB $db, string $name, array $columns) { |
|
46 | 46 | parent::__construct($db); |
47 | 47 | $this->name = $name; |
48 | 48 | foreach ($columns as $column) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - final public function __toString () { |
|
58 | + final public function __toString() { |
|
59 | 59 | return $this->name; |
60 | 60 | } |
61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $values |
66 | 66 | * @return int Rows affected. |
67 | 67 | */ |
68 | - public function apply (array $values): int { |
|
68 | + public function apply(array $values): int { |
|
69 | 69 | $columns = implode(',', array_keys($values)); |
70 | 70 | $values = $this->db->quoteList($values); |
71 | 71 | if ($this->db->isSQLite()) { |
@@ -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] ??= $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 | - public function getColumns () { |
|
123 | + public function getColumns() { |
|
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 int|string $column |
148 | 148 | * @return Column |
149 | 149 | */ |
150 | - public function offsetGet ($column) { |
|
150 | + public function offsetGet($column) { |
|
151 | 151 | if (is_int($column)) { |
152 | 152 | return current(array_slice($this->columns, $column, 1)) ?: null; |
153 | 153 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param string[] $columns |
161 | 161 | * @return Select|array[] |
162 | 162 | */ |
163 | - public function select (array $columns = ['*']) { |
|
163 | + public function select(array $columns = ['*']) { |
|
164 | 164 | return Select::factory($this->db, $this, $columns); |
165 | 165 | } |
166 | 166 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string $name |
171 | 171 | * @return Table |
172 | 172 | */ |
173 | - public function setName (string $name) { |
|
173 | + public function setName(string $name) { |
|
174 | 174 | $clone = clone $this; |
175 | 175 | $clone->name = $name; |
176 | 176 | foreach ($this->columns as $name => $column) { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param array $match |
189 | 189 | * @return int Rows affected. |
190 | 190 | */ |
191 | - public function update (array $values, array $match): int { |
|
191 | + public function update(array $values, array $match): int { |
|
192 | 192 | foreach ($this->db->quoteArray($values) as $key => $value) { |
193 | 193 | $values[$key] = "{$key} = {$value}"; |
194 | 194 | } |
@@ -16,20 +16,20 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - abstract public function __toString (); |
|
19 | + abstract public function __toString(); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Columns keyed by name/alias. |
23 | 23 | * |
24 | 24 | * @return Column[] |
25 | 25 | */ |
26 | - abstract public function getColumns (); |
|
26 | + abstract public function getColumns(); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @param int|string $column |
30 | 30 | * @return null|Column |
31 | 31 | */ |
32 | - abstract public function offsetGet ($column); |
|
32 | + abstract public function offsetGet($column); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @var DB |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @param DB $db |
41 | 41 | */ |
42 | - public function __construct (DB $db) { |
|
42 | + public function __construct(DB $db) { |
|
43 | 43 | $this->db = $db; |
44 | 44 | } |
45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param int|string $column |
48 | 48 | * @return bool |
49 | 49 | */ |
50 | - public function offsetExists ($column): bool { |
|
50 | + public function offsetExists($column): bool { |
|
51 | 51 | return $this->offsetGet($column) !== null; |
52 | 52 | } |
53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param void $value |
59 | 59 | * @throws Exception |
60 | 60 | */ |
61 | - final public function offsetSet ($offset, $value): void { |
|
61 | + final public function offsetSet($offset, $value): void { |
|
62 | 62 | throw new Exception('Tables are immutable.'); |
63 | 63 | } |
64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param void $name |
69 | 69 | * @throws Exception |
70 | 70 | */ |
71 | - final public function offsetUnset ($name): void { |
|
71 | + final public function offsetUnset($name): void { |
|
72 | 72 | $this->offsetSet($name, null); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string|AbstractTable $table |
126 | 126 | * @param string[] $columns |
127 | 127 | */ |
128 | - public function __construct (DB $db, $table, array $columns = ['*']) { |
|
128 | + public function __construct(DB $db, $table, array $columns = ['*']) { |
|
129 | 129 | static $autoAlias = 0; |
130 | 130 | $autoAlias++; |
131 | 131 | parent::__construct($db); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array $args |
153 | 153 | * @return Statement |
154 | 154 | */ |
155 | - public function __invoke (array $args = []) { |
|
155 | + public function __invoke(array $args = []) { |
|
156 | 156 | return $this->execute($args); |
157 | 157 | } |
158 | 158 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - final public function __toString () { |
|
164 | + final public function __toString() { |
|
165 | 165 | return $this->alias; |
166 | 166 | } |
167 | 167 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param array $args Execution arguments. |
172 | 172 | * @return int |
173 | 173 | */ |
174 | - public function count (array $args = []): int { |
|
174 | + public function count(array $args = []): int { |
|
175 | 175 | $clone = clone $this; |
176 | 176 | $clone->_columns = 'COUNT(*)'; |
177 | 177 | $clone->_order = ''; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param array $args |
185 | 185 | * @return Statement |
186 | 186 | */ |
187 | - public function execute (array $args = []) { |
|
187 | + public function execute(array $args = []) { |
|
188 | 188 | if (empty($args)) { |
189 | 189 | return $this->db->query($this->toSql()); |
190 | 190 | } |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | * @param array $args Execution arguments. |
200 | 200 | * @return array |
201 | 201 | */ |
202 | - public function getAll (array $args = []): array { |
|
202 | + public function getAll(array $args = []): array { |
|
203 | 203 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
207 | 207 | * @return Column[] |
208 | 208 | */ |
209 | - public function getColumns () { |
|
209 | + public function getColumns() { |
|
210 | 210 | return $this->refs; |
211 | 211 | } |
212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param array $args Execution arguments. |
220 | 220 | * @return Generator |
221 | 221 | */ |
222 | - public function getEach (array $args = []) { |
|
222 | + public function getEach(array $args = []) { |
|
223 | 223 | yield from $this->fetcher->__invoke($this->execute($args)); |
224 | 224 | } |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param array $args |
232 | 232 | * @return mixed |
233 | 233 | */ |
234 | - public function getFirst (array $args = []) { |
|
234 | + public function getFirst(array $args = []) { |
|
235 | 235 | return $this->getEach($args)->current(); |
236 | 236 | } |
237 | 237 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return Generator |
244 | 244 | */ |
245 | - public function getIterator () { |
|
245 | + public function getIterator() { |
|
246 | 246 | yield from $this->getEach(); |
247 | 247 | } |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return null|mixed |
254 | 254 | */ |
255 | - public function getResult (array $args = []) { |
|
255 | + public function getResult(array $args = []) { |
|
256 | 256 | return $this->execute($args)->fetchColumn(); |
257 | 257 | } |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param string $column |
263 | 263 | * @return $this |
264 | 264 | */ |
265 | - public function group (string $column) { |
|
265 | + public function group(string $column) { |
|
266 | 266 | if (!strlen($this->_group)) { |
267 | 267 | $this->_group = " GROUP BY {$column}"; |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string ...$conditions |
279 | 279 | * @return $this |
280 | 280 | */ |
281 | - public function having (string ...$conditions) { |
|
281 | + public function having(string ...$conditions) { |
|
282 | 282 | assert(count($conditions) > 0); |
283 | 283 | $conditions = implode(' AND ', $conditions); |
284 | 284 | if (!strlen($this->_having)) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param Select $select |
299 | 299 | * @return $this |
300 | 300 | */ |
301 | - public function intersect (Select $select) { |
|
301 | + public function intersect(Select $select) { |
|
302 | 302 | if ($this->db->isMySQL()) { |
303 | 303 | // to be standards compliant, this hack must fail if they don't have the same cols. |
304 | 304 | assert(count($this->refs) === count($select->refs) and !array_diff_key($this->refs, $select->refs)); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return Predicate |
321 | 321 | */ |
322 | - public function isEmpty () { |
|
322 | + public function isEmpty() { |
|
323 | 323 | return Predicate::factory($this->db, "NOT EXISTS ({$this->toSql()})"); |
324 | 324 | } |
325 | 325 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return Predicate |
330 | 330 | */ |
331 | - public function isNotEmpty () { |
|
331 | + public function isNotEmpty() { |
|
332 | 332 | return Predicate::factory($this->db, "EXISTS ({$this->toSql()})"); |
333 | 333 | } |
334 | 334 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @param string ...$conditions |
340 | 340 | * @return $this |
341 | 341 | */ |
342 | - public function join ($table, string ...$conditions) { |
|
342 | + public function join($table, string ...$conditions) { |
|
343 | 343 | assert(count($conditions) > 0); |
344 | 344 | if ($table instanceof Select) { |
345 | 345 | $table = $table->toSubquery(); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param string ...$conditions |
357 | 357 | * @return $this |
358 | 358 | */ |
359 | - public function joinLeft ($table, string ...$conditions) { |
|
359 | + public function joinLeft($table, string ...$conditions) { |
|
360 | 360 | assert(count($conditions) > 0); |
361 | 361 | if ($table instanceof Select) { |
362 | 362 | $table = $table->toSubquery(); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @param int $offset |
374 | 374 | * @return $this |
375 | 375 | */ |
376 | - public function limit (int $limit, int $offset = 0) { |
|
376 | + public function limit(int $limit, int $offset = 0) { |
|
377 | 377 | if ($limit == 0) { |
378 | 378 | $this->_limit = ''; |
379 | 379 | } |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @param int|string $ref Ordinal or reference name. |
393 | 393 | * @return null|Column |
394 | 394 | */ |
395 | - public function offsetGet ($ref) { |
|
395 | + public function offsetGet($ref) { |
|
396 | 396 | if (is_int($ref)) { |
397 | 397 | return current(array_slice($this->refs, $ref, 1)) ?: null; |
398 | 398 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @param string $order |
406 | 406 | * @return $this |
407 | 407 | */ |
408 | - public function order (string $order) { |
|
408 | + public function order(string $order) { |
|
409 | 409 | if (strlen($order)) { |
410 | 410 | $order = " ORDER BY {$order}"; |
411 | 411 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * @return Statement |
418 | 418 | */ |
419 | - public function prepare () { |
|
419 | + public function prepare() { |
|
420 | 420 | return $this->db->prepare($this->toSql()); |
421 | 421 | } |
422 | 422 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $alias |
425 | 425 | * @return $this |
426 | 426 | */ |
427 | - public function setAlias (string $alias) { |
|
427 | + public function setAlias(string $alias) { |
|
428 | 428 | $this->alias = $alias; |
429 | 429 | foreach ($this->refs as $k => $column) { |
430 | 430 | $this->refs[$k] = $column->setQualifier($alias); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param string[] $expressions Keyed by alias if applicable. |
442 | 442 | * @return $this |
443 | 443 | */ |
444 | - public function setColumns (array $expressions = ['*']) { |
|
444 | + public function setColumns(array $expressions = ['*']) { |
|
445 | 445 | if ($expressions === ['*']) { |
446 | 446 | $expressions = array_keys($this->table->getColumns()); |
447 | 447 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * @param Closure $fetcher |
470 | 470 | * @return $this |
471 | 471 | */ |
472 | - public function setFetcher (Closure $fetcher) { |
|
472 | + public function setFetcher(Closure $fetcher) { |
|
473 | 473 | $this->fetcher = $fetcher; |
474 | 474 | return $this; |
475 | 475 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - public function toSql (): string { |
|
482 | + public function toSql(): string { |
|
483 | 483 | $sql = "SELECT {$this->_columns} FROM {$this->_table}"; |
484 | 484 | $sql .= $this->_join; |
485 | 485 | $sql .= $this->_where; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return string |
498 | 498 | */ |
499 | - public function toSubquery (): string { |
|
499 | + public function toSubquery(): string { |
|
500 | 500 | return "({$this->toSql()}) AS {$this->alias}"; |
501 | 501 | } |
502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param Select $select |
507 | 507 | * @return $this |
508 | 508 | */ |
509 | - public function union (Select $select) { |
|
509 | + public function union(Select $select) { |
|
510 | 510 | $select = clone $select; |
511 | 511 | $select->_order = ''; |
512 | 512 | $select->_limit = ''; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param Select $select |
521 | 521 | * @return $this |
522 | 522 | */ |
523 | - public function unionAll (Select $select) { |
|
523 | + public function unionAll(Select $select) { |
|
524 | 524 | $select = clone $select; |
525 | 525 | $select->_order = ''; |
526 | 526 | $select->_limit = ''; |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @param string ...$conditions |
535 | 535 | * @return $this |
536 | 536 | */ |
537 | - public function where (string ...$conditions) { |
|
537 | + public function where(string ...$conditions) { |
|
538 | 538 | assert(count($conditions) > 0); |
539 | 539 | $conditions = implode(' AND ', $conditions); |
540 | 540 | if (!strlen($this->_where)) { |
@@ -132,8 +132,7 @@ discard block |
||
132 | 132 | if ($table instanceof Select) { |
133 | 133 | $this->_table = $table->toSubquery(); |
134 | 134 | $this->alias = "_anon{$autoAlias}_{$table->alias}"; |
135 | - } |
|
136 | - else { |
|
135 | + } else { |
|
137 | 136 | if (is_string($table)) { |
138 | 137 | $table = $db[$table]; |
139 | 138 | assert(isset($table)); |
@@ -265,8 +264,7 @@ discard block |
||
265 | 264 | public function group (string $column) { |
266 | 265 | if (!strlen($this->_group)) { |
267 | 266 | $this->_group = " GROUP BY {$column}"; |
268 | - } |
|
269 | - else { |
|
267 | + } else { |
|
270 | 268 | $this->_group .= ", {$column}"; |
271 | 269 | } |
272 | 270 | return $this; |
@@ -283,8 +281,7 @@ discard block |
||
283 | 281 | $conditions = implode(' AND ', $conditions); |
284 | 282 | if (!strlen($this->_having)) { |
285 | 283 | $this->_having = " HAVING {$conditions}"; |
286 | - } |
|
287 | - else { |
|
284 | + } else { |
|
288 | 285 | $this->_having .= " AND {$conditions}"; |
289 | 286 | } |
290 | 287 | return $this; |
@@ -376,8 +373,7 @@ discard block |
||
376 | 373 | public function limit (int $limit, int $offset = 0) { |
377 | 374 | if ($limit == 0) { |
378 | 375 | $this->_limit = ''; |
379 | - } |
|
380 | - else { |
|
376 | + } else { |
|
381 | 377 | $this->_limit = " LIMIT {$limit}"; |
382 | 378 | if ($offset > 1) { |
383 | 379 | $this->_limit .= " OFFSET {$offset}"; |
@@ -452,8 +448,7 @@ discard block |
||
452 | 448 | $name = $match['name'] ?? null; |
453 | 449 | if (is_int($alias)) { |
454 | 450 | $alias = $name; |
455 | - } |
|
456 | - elseif ($alias !== $name) { |
|
451 | + } elseif ($alias !== $name) { |
|
457 | 452 | $expr .= " AS {$alias}"; |
458 | 453 | } |
459 | 454 | if (isset($alias)) { |
@@ -539,8 +534,7 @@ discard block |
||
539 | 534 | $conditions = implode(' AND ', $conditions); |
540 | 535 | if (!strlen($this->_where)) { |
541 | 536 | $this->_where = " WHERE {$conditions}"; |
542 | - } |
|
543 | - else { |
|
537 | + } else { |
|
544 | 538 | $this->_where .= " AND {$conditions}"; |
545 | 539 | } |
546 | 540 | return $this; |
@@ -114,8 +114,7 @@ |
||
114 | 114 | $slots = implode(',', $this->db->slots(array_keys($this->columns))); |
115 | 115 | if ($this->db->isSQLite()) { |
116 | 116 | $sql = "INSERT OR IGNORE INTO {$this} ({$columns}) VALUES ({$slots})"; |
117 | - } |
|
118 | - else { |
|
117 | + } else { |
|
119 | 118 | $sql = "INSERT IGNORE INTO {$this} ({$columns}) VALUES ({$slots})"; |
120 | 119 | } |
121 | 120 | return $this->db->prepare($sql); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $interface |
35 | 35 | * @return Junction |
36 | 36 | */ |
37 | - public static function fromInterface (DB $db, string $interface) { |
|
37 | + public static function fromInterface(DB $db, string $interface) { |
|
38 | 38 | $ref = new ReflectionClass($interface); |
39 | 39 | assert($ref->isInterface()); |
40 | 40 | $doc = $ref->getDocComment(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $table |
50 | 50 | * @param string[] $classes |
51 | 51 | */ |
52 | - public function __construct (DB $db, string $table, array $classes) { |
|
52 | + public function __construct(DB $db, string $table, array $classes) { |
|
53 | 53 | parent::__construct($db, $table, array_keys($classes)); |
54 | 54 | $this->classes = $classes; |
55 | 55 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param array $match Keyed by junction column. |
64 | 64 | * @return Select|EntityInterface[] |
65 | 65 | */ |
66 | - public function findAll (string $key, array $match = []) { |
|
66 | + public function findAll(string $key, array $match = []) { |
|
67 | 67 | $record = $this->getRecord($key); |
68 | 68 | $select = $record->loadAll(); |
69 | 69 | $select->join($this, $this[$key]->isEqual($record['id'])); |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | * @param string $column |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - final public function getClass (string $column): string { |
|
80 | + final public function getClass(string $column): string { |
|
81 | 81 | return $this->classes[$column]; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @return string[] |
86 | 86 | */ |
87 | - final public function getClasses () { |
|
87 | + final public function getClasses() { |
|
88 | 88 | return $this->classes; |
89 | 89 | } |
90 | 90 | |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * @param string $column |
93 | 93 | * @return Record |
94 | 94 | */ |
95 | - public function getRecord (string $column) { |
|
95 | + public function getRecord(string $column) { |
|
96 | 96 | return $this->db->getRecord($this->classes[$column]); |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return Record[] |
101 | 101 | */ |
102 | - public function getRecords () { |
|
102 | + public function getRecords() { |
|
103 | 103 | return array_map(fn($class) => $this->db->getRecord($class), $this->classes); |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param int[] $ids Keyed by column. |
110 | 110 | * @return int Rows affected. |
111 | 111 | */ |
112 | - public function link (array $ids): int { |
|
112 | + public function link(array $ids): int { |
|
113 | 113 | $statement = $this->cache(__FUNCTION__, function() { |
114 | 114 | $columns = implode(',', array_keys($this->columns)); |
115 | 115 | $slots = implode(',', $this->db->slots(array_keys($this->columns))); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param array $ids Keyed by Column |
133 | 133 | * @return int Rows affected |
134 | 134 | */ |
135 | - public function unlink (array $ids): int { |
|
135 | + public function unlink(array $ids): int { |
|
136 | 136 | return $this->delete($ids); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -31,11 +31,11 @@ |
||
31 | 31 | * @param Schema $schema |
32 | 32 | * @return void |
33 | 33 | */ |
34 | - public function down ($schema); |
|
34 | + public function down($schema); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @param Schema $schema |
38 | 38 | * @return void |
39 | 39 | */ |
40 | - public function up ($schema); |
|
40 | + public function up($schema); |
|
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param string $name |
48 | 48 | * @param string $qualifier |
49 | 49 | */ |
50 | - public function __construct (DB $db, string $name, string $qualifier = '') { |
|
50 | + public function __construct(DB $db, string $name, string $qualifier = '') { |
|
51 | 51 | $this->db = $db; |
52 | 52 | $this->name = $name; |
53 | 53 | $this->qualifier = $qualifier; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public function __toString () { |
|
61 | + public function __toString() { |
|
62 | 62 | if (strlen($this->qualifier)) { |
63 | 63 | return "{$this->qualifier}.{$this->name}"; |
64 | 64 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - final public function getName (): string { |
|
71 | + final public function getName(): string { |
|
72 | 72 | return $this->name; |
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @return string |
77 | 77 | */ |
78 | - final public function getQualifier (): string { |
|
78 | + final public function getQualifier(): string { |
|
79 | 79 | return $this->qualifier; |
80 | 80 | } |
81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param mixed $value |
86 | 86 | * @return true |
87 | 87 | */ |
88 | - final public function offsetExists ($value) { |
|
88 | + final public function offsetExists($value) { |
|
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param string $aggregator |
99 | 99 | * @return null|string |
100 | 100 | */ |
101 | - public function offsetGet ($aggregator) { |
|
101 | + public function offsetGet($aggregator) { |
|
102 | 102 | $aggregator = preg_replace('/[ _()]/', '', $aggregator); // accept a variety of forms |
103 | 103 | $aggregator = $this->{$aggregator}(); // methods are not case sensitive |
104 | 104 | return Select::factory($this->db, $this->qualifier, [$aggregator])->getResult(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param mixed $value |
112 | 112 | * @throws LogicException |
113 | 113 | */ |
114 | - final public function offsetSet ($offset, $value) { |
|
114 | + final public function offsetSet($offset, $value) { |
|
115 | 115 | throw new LogicException("Column aggregation is read-only"); |
116 | 116 | } |
117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param mixed $offset |
122 | 122 | * @throws LogicException |
123 | 123 | */ |
124 | - final public function offsetUnset ($offset) { |
|
124 | + final public function offsetUnset($offset) { |
|
125 | 125 | throw new LogicException("Column aggregation is read-only"); |
126 | 126 | } |
127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return Select|scalar[] |
132 | 132 | */ |
133 | - public function select () { |
|
133 | + public function select() { |
|
134 | 134 | return Select::factory($this->db, $this->qualifier, [$this->name]) |
135 | 135 | ->setFetcher(function(Statement $statement) { |
136 | 136 | while (false !== $value = $statement->fetchColumn()) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string $name |
148 | 148 | * @return $this |
149 | 149 | */ |
150 | - public function setName (string $name) { |
|
150 | + public function setName(string $name) { |
|
151 | 151 | $clone = clone $this; |
152 | 152 | $clone->name = $name; |
153 | 153 | return $clone; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $qualifier |
158 | 158 | * @return $this |
159 | 159 | */ |
160 | - public function setQualifier (string $qualifier) { |
|
160 | + public function setQualifier(string $qualifier) { |
|
161 | 161 | $clone = clone $this; |
162 | 162 | $clone->qualifier = $qualifier; |
163 | 163 | return $clone; |