@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $passwd |
53 | 53 | * @param array $options |
54 | 54 | */ |
55 | - public function __construct ($dsn, $username = null, $passwd = null, $options = null) { |
|
55 | + public function __construct($dsn, $username = null, $passwd = null, $options = null) { |
|
56 | 56 | parent::__construct($dsn, $username, $passwd, $options); |
57 | 57 | $this->driver = $this->getAttribute(self::ATTR_DRIVER_NAME); |
58 | 58 | $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - final public function __toString () { |
|
76 | + final public function __toString() { |
|
77 | 77 | return $this->driver; |
78 | 78 | } |
79 | 79 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string $sql |
84 | 84 | * @return int |
85 | 85 | */ |
86 | - public function exec ($sql): int { |
|
86 | + public function exec($sql): int { |
|
87 | 87 | $this->logger->__invoke($sql); |
88 | 88 | return parent::exec($sql); |
89 | 89 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - final public function getDriver (): string { |
|
94 | + final public function getDriver(): string { |
|
95 | 95 | return $this->driver; |
96 | 96 | } |
97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $interface |
102 | 102 | * @return Junction |
103 | 103 | */ |
104 | - public function getJunction ($interface) { |
|
104 | + public function getJunction($interface) { |
|
105 | 105 | if (!isset($this->junctions[$interface])) { |
106 | 106 | $this->junctions[$interface] = Junction::fromInterface($this, $interface); |
107 | 107 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * @return Closure |
113 | 113 | */ |
114 | - public function getLogger () { |
|
114 | + public function getLogger() { |
|
115 | 115 | return $this->logger; |
116 | 116 | } |
117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param string|EntityInterface $class |
122 | 122 | * @return Record |
123 | 123 | */ |
124 | - public function getRecord ($class) { |
|
124 | + public function getRecord($class) { |
|
125 | 125 | $name = $class; |
126 | 126 | if (is_object($name)) { |
127 | 127 | $name = get_class($name); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param mixed $b |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - public function match ($a, $b) { |
|
151 | + public function match($a, $b) { |
|
152 | 152 | if ($b instanceof Closure) { |
153 | 153 | if (!$a instanceof Column) { |
154 | 154 | $a = new Column($this, $a); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param array $match |
175 | 175 | * @return string[] |
176 | 176 | */ |
177 | - public function matchArray (array $match) { |
|
177 | + public function matchArray(array $match) { |
|
178 | 178 | return array_map([$this, 'match'], array_keys($match), $match); |
179 | 179 | } |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param string $class Class or interface name. |
183 | 183 | * @return bool |
184 | 184 | */ |
185 | - public function offsetExists ($class): bool { |
|
185 | + public function offsetExists($class): bool { |
|
186 | 186 | return (bool)$this->offsetGet($class); |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $class Class or interface name. |
191 | 191 | * @return null|Record|Junction |
192 | 192 | */ |
193 | - public function offsetGet ($class) { |
|
193 | + public function offsetGet($class) { |
|
194 | 194 | if (class_exists($class)) { |
195 | 195 | return $this->getRecord($class); |
196 | 196 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param string $class Class or interface name. |
205 | 205 | * @param Record|Junction $access |
206 | 206 | */ |
207 | - public function offsetSet ($class, $access) { |
|
207 | + public function offsetSet($class, $access) { |
|
208 | 208 | if ($access instanceof Record) { |
209 | 209 | $this->setRecord($class, $access); |
210 | 210 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * @param string $class Class or interface name. |
218 | 218 | */ |
219 | - public function offsetUnset ($class) { |
|
219 | + public function offsetUnset($class) { |
|
220 | 220 | unset($this->records[$class]); |
221 | 221 | unset($this->junctions[$class]); |
222 | 222 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $options |
229 | 229 | * @return Statement |
230 | 230 | */ |
231 | - public function prepare ($sql, $options = []) { |
|
231 | + public function prepare($sql, $options = []) { |
|
232 | 232 | $this->logger->__invoke($sql); |
233 | 233 | /** @var Statement $statement */ |
234 | 234 | $statement = parent::prepare($sql, $options); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param array $ctorargs |
245 | 245 | * @return Statement |
246 | 246 | */ |
247 | - public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
247 | + public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) { |
|
248 | 248 | $this->logger->__invoke($sql); |
249 | 249 | /** @var Statement $statement */ |
250 | 250 | $statement = parent::query(...func_get_args()); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param int $type Ignored. |
264 | 264 | * @return string |
265 | 265 | */ |
266 | - public function quote ($value, $type = null) { |
|
266 | + public function quote($value, $type = null) { |
|
267 | 267 | if ($value instanceof ExpressionInterface) { |
268 | 268 | return $value; |
269 | 269 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param array $values |
284 | 284 | * @return string[] |
285 | 285 | */ |
286 | - public function quoteArray (array $values): array { |
|
286 | + public function quoteArray(array $values): array { |
|
287 | 287 | return array_map([$this, 'quote'], $values); |
288 | 288 | } |
289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param array $values |
294 | 294 | * @return string |
295 | 295 | */ |
296 | - public function quoteList (array $values): string { |
|
296 | + public function quoteList(array $values): string { |
|
297 | 297 | return implode(',', $this->quoteArray($values)); |
298 | 298 | } |
299 | 299 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param mixed $value |
304 | 304 | * @return string|string[] |
305 | 305 | */ |
306 | - public function quoteMixed ($value) { |
|
306 | + public function quoteMixed($value) { |
|
307 | 307 | if (is_array($value)) { |
308 | 308 | return $this->quoteArray($value); |
309 | 309 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param EntityInterface $entity |
317 | 317 | * @return int ID |
318 | 318 | */ |
319 | - public function save (EntityInterface $entity): int { |
|
319 | + public function save(EntityInterface $entity): int { |
|
320 | 320 | return $this->getRecord($entity)->save($entity); |
321 | 321 | } |
322 | 322 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @param Junction $junction |
326 | 326 | * @return $this |
327 | 327 | */ |
328 | - public function setJunction (string $interface, Junction $junction) { |
|
328 | + public function setJunction(string $interface, Junction $junction) { |
|
329 | 329 | $this->junctions[$interface] = $junction; |
330 | 330 | return $this; |
331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param Closure $logger |
335 | 335 | * @return $this |
336 | 336 | */ |
337 | - public function setLogger (Closure $logger) { |
|
337 | + public function setLogger(Closure $logger) { |
|
338 | 338 | $this->logger = $logger; |
339 | 339 | return $this; |
340 | 340 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param Record $record |
345 | 345 | * @return $this |
346 | 346 | */ |
347 | - public function setRecord (string $class, Record $record) { |
|
347 | + public function setRecord(string $class, Record $record) { |
|
348 | 348 | $this->records[$class] = $record; |
349 | 349 | return $this; |
350 | 350 | } |
@@ -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 = implode(', ', $this->db->quoteArray($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 |
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 ($this->db->matchArray($match) as $condition) { |
98 | 98 | $select->where($condition); |
@@ -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 | $match = Predicate::all($this->db->matchArray($match)); |
113 | 113 | return $this->db->exec("DELETE FROM {$this} WHERE {$match}"); |
114 | 114 | } |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * @return Column[] |
118 | 118 | */ |
119 | - final public function getColumns (): array { |
|
119 | + final public function getColumns(): array { |
|
120 | 120 | return $this->columns; |
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - final public function getName (): string { |
|
126 | + final public function getName(): string { |
|
127 | 127 | return $this->name; |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param array $values |
134 | 134 | * @return Statement |
135 | 135 | */ |
136 | - public function insert (array $values) { |
|
136 | + public function insert(array $values) { |
|
137 | 137 | $columns = implode(',', array_keys($values)); |
138 | 138 | $values = implode(', ', $this->db->quoteArray($values)); |
139 | 139 | return $this->db->query("INSERT INTO {$this} ($columns) VALUES ($values)"); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $name |
144 | 144 | * @return bool |
145 | 145 | */ |
146 | - public function offsetExists ($name): bool { |
|
146 | + public function offsetExists($name): bool { |
|
147 | 147 | return isset($this->columns[$name]); |
148 | 148 | } |
149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param string $name |
152 | 152 | * @return Column |
153 | 153 | */ |
154 | - public function offsetGet ($name) { |
|
154 | + public function offsetGet($name) { |
|
155 | 155 | return $this->columns[$name]; |
156 | 156 | } |
157 | 157 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param string[] $columns Defaults to all columns. |
162 | 162 | * @return Select |
163 | 163 | */ |
164 | - public function select (array $columns = []) { |
|
164 | + public function select(array $columns = []) { |
|
165 | 165 | if (empty($columns)) { |
166 | 166 | $columns = $this->columns; |
167 | 167 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param string $name |
175 | 175 | * @return Table |
176 | 176 | */ |
177 | - public function setName (string $name) { |
|
177 | + public function setName(string $name) { |
|
178 | 178 | $clone = clone $this; |
179 | 179 | $clone->name = $name; |
180 | 180 | foreach ($this->columns as $name => $column) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param array $match |
193 | 193 | * @return int Rows affected. |
194 | 194 | */ |
195 | - public function update (array $values, array $match): int { |
|
195 | + public function update(array $values, array $match): int { |
|
196 | 196 | $values = implode(', ', $this->db->matchArray($values)); |
197 | 197 | $match = Predicate::all($this->db->matchArray($match)); |
198 | 198 | return $this->db->exec("UPDATE {$this} SET {$values} WHERE {$match}"); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string|Select $table |
107 | 107 | * @param string[] $columns |
108 | 108 | */ |
109 | - public function __construct (DB $db, $table, array $columns) { |
|
109 | + public function __construct(DB $db, $table, array $columns) { |
|
110 | 110 | parent::__construct($db); |
111 | 111 | if ($table instanceof Select) { |
112 | 112 | $this->table = $table->toSubquery(); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param array $args |
127 | 127 | * @return Statement |
128 | 128 | */ |
129 | - public function __invoke (array $args = []) { |
|
129 | + public function __invoke(array $args = []) { |
|
130 | 130 | return $this->execute($args); |
131 | 131 | } |
132 | 132 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - final public function __toString () { |
|
138 | + final public function __toString() { |
|
139 | 139 | return $this->alias; |
140 | 140 | } |
141 | 141 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param array $args Execution arguments. |
146 | 146 | * @return int |
147 | 147 | */ |
148 | - public function count (array $args = []): int { |
|
148 | + public function count(array $args = []): int { |
|
149 | 149 | $clone = clone $this; |
150 | 150 | $clone->_columns = 'COUNT(*)'; |
151 | 151 | $clone->_order = ''; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param array $args |
159 | 159 | * @return Statement |
160 | 160 | */ |
161 | - public function execute (array $args = []) { |
|
161 | + public function execute(array $args = []) { |
|
162 | 162 | if (empty($args)) { |
163 | 163 | return $this->db->query($this->toSql()); |
164 | 164 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $args Execution arguments. |
174 | 174 | * @return array |
175 | 175 | */ |
176 | - public function getAll (array $args = []): array { |
|
176 | + public function getAll(array $args = []): array { |
|
177 | 177 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
178 | 178 | } |
179 | 179 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param array $args Execution arguments. |
187 | 187 | * @return Generator |
188 | 188 | */ |
189 | - public function getEach (array $args = []) { |
|
189 | + public function getEach(array $args = []) { |
|
190 | 190 | yield from $this->fetcher->__invoke($this->execute($args)); |
191 | 191 | } |
192 | 192 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param array $args |
199 | 199 | * @return mixed |
200 | 200 | */ |
201 | - public function getFirst (array $args = []) { |
|
201 | + public function getFirst(array $args = []) { |
|
202 | 202 | return $this->getEach($args)->current(); |
203 | 203 | } |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @return Generator |
211 | 211 | */ |
212 | - public function getIterator () { |
|
212 | + public function getIterator() { |
|
213 | 213 | yield from $this->getEach(); |
214 | 214 | } |
215 | 215 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param string $column |
220 | 220 | * @return $this |
221 | 221 | */ |
222 | - public function group (string $column) { |
|
222 | + public function group(string $column) { |
|
223 | 223 | if (!strlen($this->_group)) { |
224 | 224 | $this->_group = " GROUP BY {$column}"; |
225 | 225 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param string $condition |
236 | 236 | * @return $this |
237 | 237 | */ |
238 | - public function having (string $condition) { |
|
238 | + public function having(string $condition) { |
|
239 | 239 | if (!strlen($this->_having)) { |
240 | 240 | $this->_having = " HAVING {$condition}"; |
241 | 241 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return Predicate |
252 | 252 | */ |
253 | - public function isCorrelated () { |
|
253 | + public function isCorrelated() { |
|
254 | 254 | return new Predicate("EXISTS ({$this->toSql()})"); |
255 | 255 | } |
256 | 256 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return Predicate |
261 | 261 | */ |
262 | - public function isNotCorrelated () { |
|
262 | + public function isNotCorrelated() { |
|
263 | 263 | return new Predicate("NOT EXISTS ({$this->toSql()})"); |
264 | 264 | } |
265 | 265 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param string $type |
272 | 272 | * @return $this |
273 | 273 | */ |
274 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
274 | + public function join($table, string $condition, string $type = 'INNER') { |
|
275 | 275 | if ($table instanceof Select) { |
276 | 276 | $table = $table->toSubquery(); |
277 | 277 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param int $offset |
287 | 287 | * @return $this |
288 | 288 | */ |
289 | - public function limit (int $limit, int $offset = 0) { |
|
289 | + public function limit(int $limit, int $offset = 0) { |
|
290 | 290 | if ($limit == 0) { |
291 | 291 | $this->_limit = ''; |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @param mixed $offset Ordinal or reference name. |
306 | 306 | * @return bool |
307 | 307 | */ |
308 | - public function offsetExists ($offset): bool { |
|
308 | + public function offsetExists($offset): bool { |
|
309 | 309 | return isset($this->referable[$offset]); |
310 | 310 | } |
311 | 311 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param mixed $offset Ordinal or reference name. |
316 | 316 | * @return Column |
317 | 317 | */ |
318 | - public function offsetGet ($offset) { |
|
318 | + public function offsetGet($offset) { |
|
319 | 319 | return new Column($this->db, $this->referable[$offset], $this->alias); |
320 | 320 | } |
321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @param string $order |
326 | 326 | * @return $this |
327 | 327 | */ |
328 | - public function order (string $order) { |
|
328 | + public function order(string $order) { |
|
329 | 329 | if (strlen($order)) { |
330 | 330 | $order = " ORDER BY {$order}"; |
331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * @return Statement |
338 | 338 | */ |
339 | - public function prepare () { |
|
339 | + public function prepare() { |
|
340 | 340 | return $this->db->prepare($this->toSql()); |
341 | 341 | } |
342 | 342 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param string $alias |
345 | 345 | * @return $this |
346 | 346 | */ |
347 | - public function setAlias (string $alias) { |
|
347 | + public function setAlias(string $alias) { |
|
348 | 348 | $this->alias = $alias; |
349 | 349 | return $this; |
350 | 350 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param string[] $columns |
354 | 354 | * @return $this |
355 | 355 | */ |
356 | - public function setColumns (array $columns) { |
|
356 | + public function setColumns(array $columns) { |
|
357 | 357 | $this->referable = []; |
358 | 358 | $_columns = []; |
359 | 359 | $i = 0; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * @param Closure $fetcher |
386 | 386 | * @return $this |
387 | 387 | */ |
388 | - public function setFetcher (Closure $fetcher) { |
|
388 | + public function setFetcher(Closure $fetcher) { |
|
389 | 389 | $this->fetcher = $fetcher; |
390 | 390 | return $this; |
391 | 391 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public function toSql (): string { |
|
398 | + public function toSql(): string { |
|
399 | 399 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
400 | 400 | $sql .= $this->_join; |
401 | 401 | $sql .= $this->_where; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - public function toSubquery (): string { |
|
414 | + public function toSubquery(): string { |
|
415 | 415 | return "({$this->toSql()}) AS {$this->alias}"; |
416 | 416 | } |
417 | 417 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * @param string $condition |
422 | 422 | * @return $this |
423 | 423 | */ |
424 | - public function where (string $condition) { |
|
424 | + public function where(string $condition) { |
|
425 | 425 | if (!strlen($this->_where)) { |
426 | 426 | $this->_where = " WHERE {$condition}"; |
427 | 427 | } |
@@ -111,8 +111,7 @@ discard block |
||
111 | 111 | if ($table instanceof Select) { |
112 | 112 | $this->table = $table->toSubquery(); |
113 | 113 | $this->alias = uniqid('_') . "_{$table->alias}"; |
114 | - } |
|
115 | - else { |
|
114 | + } else { |
|
116 | 115 | $this->table = (string)$table; |
117 | 116 | $this->alias = uniqid('_') . "__{$table}"; |
118 | 117 | } |
@@ -222,8 +221,7 @@ discard block |
||
222 | 221 | public function group (string $column) { |
223 | 222 | if (!strlen($this->_group)) { |
224 | 223 | $this->_group = " GROUP BY {$column}"; |
225 | - } |
|
226 | - else { |
|
224 | + } else { |
|
227 | 225 | $this->_group .= ", {$column}"; |
228 | 226 | } |
229 | 227 | return $this; |
@@ -238,8 +236,7 @@ discard block |
||
238 | 236 | public function having (string $condition) { |
239 | 237 | if (!strlen($this->_having)) { |
240 | 238 | $this->_having = " HAVING {$condition}"; |
241 | - } |
|
242 | - else { |
|
239 | + } else { |
|
243 | 240 | $this->_having .= " AND {$condition}"; |
244 | 241 | } |
245 | 242 | return $this; |
@@ -289,8 +286,7 @@ discard block |
||
289 | 286 | public function limit (int $limit, int $offset = 0) { |
290 | 287 | if ($limit == 0) { |
291 | 288 | $this->_limit = ''; |
292 | - } |
|
293 | - else { |
|
289 | + } else { |
|
294 | 290 | $this->_limit = " LIMIT {$limit}"; |
295 | 291 | if ($offset > 1) { |
296 | 292 | $this->_limit .= " OFFSET {$offset}"; |
@@ -367,8 +363,7 @@ discard block |
||
367 | 363 | } |
368 | 364 | if ($name !== $alias) { |
369 | 365 | $_columns[] = "{$column} AS {$alias}"; |
370 | - } |
|
371 | - else { |
|
366 | + } else { |
|
372 | 367 | $_columns[] = "{$column}"; |
373 | 368 | } |
374 | 369 | if (is_string($name)) { |
@@ -424,8 +419,7 @@ discard block |
||
424 | 419 | public function where (string $condition) { |
425 | 420 | if (!strlen($this->_where)) { |
426 | 421 | $this->_where = " WHERE {$condition}"; |
427 | - } |
|
428 | - else { |
|
422 | + } else { |
|
429 | 423 | $this->_where .= " AND {$condition}"; |
430 | 424 | } |
431 | 425 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string|EntityInterface $class |
60 | 60 | * @return Record |
61 | 61 | */ |
62 | - public static function fromClass (DB $db, $class) { |
|
62 | + public static function fromClass(DB $db, $class) { |
|
63 | 63 | try { |
64 | 64 | $rClass = new ReflectionClass($class); |
65 | 65 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string[] $columns Property names. |
93 | 93 | * @param EAV[] $eav Keyed by property name. |
94 | 94 | */ |
95 | - public function __construct (DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
95 | + public function __construct(DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) { |
|
96 | 96 | parent::__construct($db, $table, $columns); |
97 | 97 | $this->proto = $proto; |
98 | 98 | try { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param array[] $eavMatch Additional `[eav property => attribute => mixed]` |
129 | 129 | * @return Select |
130 | 130 | */ |
131 | - public function find (array $match, array $eavMatch = []) { |
|
131 | + public function find(array $match, array $eavMatch = []) { |
|
132 | 132 | $select = $this->select(); |
133 | 133 | foreach ($this->db->matchArray($match) as $condition) { |
134 | 134 | $select->where($condition); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param Statement $statement |
147 | 147 | * @return EntityInterface[] Enumerated |
148 | 148 | */ |
149 | - public function getAll (Statement $statement): array { |
|
149 | + public function getAll(Statement $statement): array { |
|
150 | 150 | return iterator_to_array($this->getEach($statement)); |
151 | 151 | } |
152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param Statement $statement |
158 | 158 | * @return Generator |
159 | 159 | */ |
160 | - public function getEach (Statement $statement) { |
|
160 | + public function getEach(Statement $statement) { |
|
161 | 161 | do { |
162 | 162 | $entities = []; |
163 | 163 | for ($i = 0; $i < 256 and false !== $row = $statement->fetch(); $i++) { |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * @param string $property |
176 | 176 | * @return EAV |
177 | 177 | */ |
178 | - final public function getEav (string $property) { |
|
178 | + final public function getEav(string $property) { |
|
179 | 179 | return $this->eav[$property]; |
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | 183 | * @return EntityInterface |
184 | 184 | */ |
185 | - public function getProto () { |
|
185 | + public function getProto() { |
|
186 | 186 | return $this->proto; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param EntityInterface $entity |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - protected function getValues (EntityInterface $entity): array { |
|
193 | + protected function getValues(EntityInterface $entity): array { |
|
194 | 194 | $values = []; |
195 | 195 | foreach (array_keys($this->columns) as $name) { |
196 | 196 | $values[$name] = $this->properties[$name]->getValue($entity); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param int $id |
205 | 205 | * @return null|EntityInterface |
206 | 206 | */ |
207 | - public function load (int $id) { |
|
207 | + public function load(int $id) { |
|
208 | 208 | $load = $this->cache(__FUNCTION__, function() { |
209 | 209 | return $this->select(array_keys($this->columns))->where('id = ?')->prepare(); |
210 | 210 | }); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @param EntityInterface[] $entities |
224 | 224 | */ |
225 | - protected function loadEav (array $entities): void { |
|
225 | + protected function loadEav(array $entities): void { |
|
226 | 226 | $ids = array_keys($entities); |
227 | 227 | foreach ($this->eav as $name => $eav) { |
228 | 228 | foreach ($eav->loadAll($ids) as $id => $values) { |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param EntityInterface $entity |
240 | 240 | * @return int ID |
241 | 241 | */ |
242 | - public function save (EntityInterface $entity): int { |
|
242 | + public function save(EntityInterface $entity): int { |
|
243 | 243 | if (!$entity->getId()) { |
244 | 244 | $this->saveInsert($entity); |
245 | 245 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | /** |
254 | 254 | * @param EntityInterface $entity |
255 | 255 | */ |
256 | - protected function saveEav (EntityInterface $entity): void { |
|
256 | + protected function saveEav(EntityInterface $entity): void { |
|
257 | 257 | $id = $entity->getId(); |
258 | 258 | foreach ($this->eav as $name => $eav) { |
259 | 259 | $values = $this->properties[$name]->getValue($entity); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @param EntityInterface $entity |
270 | 270 | */ |
271 | - protected function saveInsert (EntityInterface $entity): void { |
|
271 | + protected function saveInsert(EntityInterface $entity): void { |
|
272 | 272 | $insert = $this->cache(__FUNCTION__, function() { |
273 | 273 | $slots = SQL::slots(array_keys($this->columns)); |
274 | 274 | unset($slots['id']); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param EntityInterface $entity |
288 | 288 | */ |
289 | - protected function saveUpdate (EntityInterface $entity): void { |
|
289 | + protected function saveUpdate(EntityInterface $entity): void { |
|
290 | 290 | $this->cache(__FUNCTION__, function() { |
291 | 291 | $slots = SQL::slotsEqual(array_keys($this->columns)); |
292 | 292 | unset($slots['id']); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param array $columns Defaults to all columns. |
302 | 302 | * @return Select |
303 | 303 | */ |
304 | - public function select (array $columns = []) { |
|
304 | + public function select(array $columns = []) { |
|
305 | 305 | $select = parent::select($columns); |
306 | 306 | if (empty($columns)) { |
307 | 307 | $select->setFetcher(function(Statement $statement) { |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param EntityInterface $proto |
316 | 316 | * @return $this |
317 | 317 | */ |
318 | - public function setProto (EntityInterface $proto) { |
|
318 | + public function setProto(EntityInterface $proto) { |
|
319 | 319 | $this->proto = $proto; |
320 | 320 | return $this; |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param EntityInterface $entity |
325 | 325 | * @param array $values |
326 | 326 | */ |
327 | - protected function setValues (EntityInterface $entity, array $values): void { |
|
327 | + protected function setValues(EntityInterface $entity, array $values): void { |
|
328 | 328 | foreach ($values as $name => $value) { |
329 | 329 | settype($value, $this->types[$name]); |
330 | 330 | $this->properties[$name]->setValue($entity, $value); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param string[] $conditions |
18 | 18 | * @return Predicate |
19 | 19 | */ |
20 | - public static function all (array $conditions) { |
|
20 | + public static function all(array $conditions) { |
|
21 | 21 | if (count($conditions) === 1) { |
22 | 22 | return reset($conditions); |
23 | 23 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string[] $conditions |
31 | 31 | * @return Predicate |
32 | 32 | */ |
33 | - public static function any (array $conditions) { |
|
33 | + public static function any(array $conditions) { |
|
34 | 34 | if (count($conditions) === 1) { |
35 | 35 | return reset($conditions); |
36 | 36 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param string $listOper |
57 | 57 | * @return Predicate |
58 | 58 | */ |
59 | - public static function compare ($a, $b, $oper = '=', $listOper = 'IN') { |
|
59 | + public static function compare($a, $b, $oper = '=', $listOper = 'IN') { |
|
60 | 60 | if (is_array($b)) { |
61 | 61 | return new static("{$a} {$listOper} (" . implode(',', $b) . ")"); |
62 | 62 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param string $listOper |
78 | 78 | * @return Predicate[] |
79 | 79 | */ |
80 | - public static function compareArray (array $values, $oper = '=', $listOper = 'IN') { |
|
80 | + public static function compareArray(array $values, $oper = '=', $listOper = 'IN') { |
|
81 | 81 | foreach ($values as $a => $b) { |
82 | 82 | $values[$a] = static::compare($a, $b, $oper, $listOper); |
83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return Predicate |
91 | 91 | */ |
92 | - public function invert () { |
|
92 | + public function invert() { |
|
93 | 93 | return new static("NOT({$this})"); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | \ No newline at end of file |
@@ -59,8 +59,7 @@ |
||
59 | 59 | public static function compare ($a, $b, $oper = '=', $listOper = 'IN') { |
60 | 60 | if (is_array($b)) { |
61 | 61 | return new static("{$a} {$listOper} (" . implode(',', $b) . ")"); |
62 | - } |
|
63 | - elseif ($b instanceof Select) { |
|
62 | + } elseif ($b instanceof Select) { |
|
64 | 63 | return new static("{$a} {$listOper} ({$b->toSql()})"); |
65 | 64 | } |
66 | 65 | return new static("{$a} {$oper} {$b}"); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return Text |
21 | 21 | */ |
22 | - public function getDate () { |
|
22 | + public function getDate() { |
|
23 | 23 | return new Text($this->db, $this->getDateTimeFormat('%Y-%m-%d')); |
24 | 24 | } |
25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|array $format Format, or formats keyed by driver name. |
30 | 30 | * @return Text |
31 | 31 | */ |
32 | - public function getDateTimeFormat ($format) { |
|
32 | + public function getDateTimeFormat($format) { |
|
33 | 33 | $driver = $this->db->getDriver(); |
34 | 34 | if (is_array($format)) { |
35 | 35 | $format = $format[$driver]; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return Numeric |
50 | 50 | */ |
51 | - public function getDay () { |
|
51 | + public function getDay() { |
|
52 | 52 | return new Numeric($this->db, $this->getDateTimeFormat('%d')); |
53 | 53 | } |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return Numeric |
59 | 59 | */ |
60 | - public function getDayOfWeek () { |
|
60 | + public function getDayOfWeek() { |
|
61 | 61 | return new Numeric($this->db, $this->getDateTimeFormat('%w')); |
62 | 62 | } |
63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return Numeric |
68 | 68 | */ |
69 | - public function getDayOfYear () { |
|
69 | + public function getDayOfYear() { |
|
70 | 70 | return new Numeric($this->db, $this->getDateTimeFormat('%j')); |
71 | 71 | } |
72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return Numeric |
77 | 77 | */ |
78 | - public function getHours () { |
|
78 | + public function getHours() { |
|
79 | 79 | return new Numeric($this->db, $this->getDateTimeFormat('%H')); |
80 | 80 | } |
81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return Numeric |
86 | 86 | */ |
87 | - public function getMinutes () { |
|
87 | + public function getMinutes() { |
|
88 | 88 | return new Numeric($this->db, $this->getDateTimeFormat([ |
89 | 89 | 'mysql' => '%i', |
90 | 90 | 'sqlite' => '%M' |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return Numeric |
98 | 98 | */ |
99 | - public function getMonth () { |
|
99 | + public function getMonth() { |
|
100 | 100 | return new Numeric($this->db, $this->getDateTimeFormat('%m')); |
101 | 101 | } |
102 | 102 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return Numeric |
107 | 107 | */ |
108 | - public function getSeconds () { |
|
108 | + public function getSeconds() { |
|
109 | 109 | return new Numeric($this->db, $this->getDateTimeFormat('%S')); |
110 | 110 | } |
111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return Text |
116 | 116 | */ |
117 | - public function getTime () { |
|
117 | + public function getTime() { |
|
118 | 118 | return new Text($this->db, $this->getDateTimeFormat([ |
119 | 119 | 'mysql' => '%H:%i:%S', |
120 | 120 | 'sqlite' => '%H:%M:%S' |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return Numeric |
128 | 128 | */ |
129 | - public function getTimestamp () { |
|
129 | + public function getTimestamp() { |
|
130 | 130 | switch ($this->db) { |
131 | 131 | case 'sqlite': |
132 | 132 | return new Numeric($this->db, "STRFTIME('%s',{$this})"); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return Numeric |
142 | 142 | */ |
143 | - public function getWeekOfYear () { |
|
143 | + public function getWeekOfYear() { |
|
144 | 144 | return new Numeric($this->db, $this->getDateTimeFormat([ |
145 | 145 | 'mysql' => '%U', |
146 | 146 | 'sqlite' => '%W' |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return Numeric |
154 | 154 | */ |
155 | - public function getYear () { |
|
155 | + public function getYear() { |
|
156 | 156 | return new Numeric($this->db, $this->getDateTimeFormat('%Y')); |
157 | 157 | } |
158 | 158 | } |
159 | 159 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return Numeric |
16 | 16 | */ |
17 | - public function toFloat () { |
|
17 | + public function toFloat() { |
|
18 | 18 | switch ($this->db) { |
19 | 19 | case 'sqlite': |
20 | 20 | return new Numeric($this->db, "CAST({$this} AS REAL)"); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return Numeric |
30 | 30 | */ |
31 | - public function toInt () { |
|
31 | + public function toInt() { |
|
32 | 32 | switch ($this->db) { |
33 | 33 | case 'sqlite': |
34 | 34 | return new Numeric($this->db, "CAST({$this} AS INTEGER)"); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param array $values |
29 | 29 | * @return Value |
30 | 30 | */ |
31 | - public function coalesce (array $values) { |
|
31 | + public function coalesce(array $values) { |
|
32 | 32 | array_unshift($values, $this); |
33 | 33 | $values = $this->db->quoteList($values); |
34 | 34 | return new Value($this->db, "COALESCE({$values})"); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param array $values `[when => then]` |
41 | 41 | * @return Choice |
42 | 42 | */ |
43 | - public function getChoice (array $values) { |
|
43 | + public function getChoice(array $values) { |
|
44 | 44 | return new Choice($this->db, "{$this}", $values); |
45 | 45 | } |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param null|bool|number|string|Select $arg |
54 | 54 | * @return Predicate |
55 | 55 | */ |
56 | - public function is ($arg): Predicate { |
|
56 | + public function is($arg): Predicate { |
|
57 | 57 | if ($arg === null or is_bool($arg)) { |
58 | 58 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
59 | 59 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param number|string $max |
80 | 80 | * @return Predicate |
81 | 81 | */ |
82 | - public function isBetween ($min, $max) { |
|
82 | + public function isBetween($min, $max) { |
|
83 | 83 | $min = $this->db->quote($min); |
84 | 84 | $max = $this->db->quote($max); |
85 | 85 | return new Predicate("{$this} BETWEEN {$min} AND {$max}"); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param bool|number|string|array|Select $arg |
92 | 92 | * @return Predicate |
93 | 93 | */ |
94 | - public function isEqual ($arg) { |
|
94 | + public function isEqual($arg) { |
|
95 | 95 | return Predicate::compare($this, $this->db->quoteMixed($arg)); |
96 | 96 | } |
97 | 97 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param number|string|Select $arg |
105 | 105 | * @return Predicate |
106 | 106 | */ |
107 | - public function isGreater ($arg) { |
|
107 | + public function isGreater($arg) { |
|
108 | 108 | if ($arg instanceof Select and $this->db == 'sqlite') { |
109 | 109 | $sub = new Select($this->db, $arg, [$arg[0]]); |
110 | 110 | return $sub->where("{$this} <= {$arg[0]}")->isNotCorrelated(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param number|string|Select $arg |
122 | 122 | * @return Predicate |
123 | 123 | */ |
124 | - public function isGreaterOrEqual ($arg) { |
|
124 | + public function isGreaterOrEqual($arg) { |
|
125 | 125 | if ($arg instanceof Select and $this->db == 'sqlite') { |
126 | 126 | $sub = new Select($this->db, $arg, [$arg[0]]); |
127 | 127 | return $sub->where("{$this} < {$arg[0]}")->isNotCorrelated(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param number|string|Select $arg |
139 | 139 | * @return Predicate |
140 | 140 | */ |
141 | - public function isLess ($arg) { |
|
141 | + public function isLess($arg) { |
|
142 | 142 | if ($arg instanceof Select and $this->db == 'sqlite') { |
143 | 143 | $sub = new Select($this->db, $arg, [$arg[0]]); |
144 | 144 | return $sub->where("{$this} >= {$arg[0]}")->isNotCorrelated(); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param number|string|Select $arg |
156 | 156 | * @return Predicate |
157 | 157 | */ |
158 | - public function isLessOrEqual ($arg) { |
|
158 | + public function isLessOrEqual($arg) { |
|
159 | 159 | if ($arg instanceof Select and $this->db == 'sqlite') { |
160 | 160 | $sub = new Select($this->db, $arg, [$arg[0]]); |
161 | 161 | return $sub->where("{$this} > {$arg[0]}")->isNotCorrelated(); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param string $pattern |
170 | 170 | * @return Predicate |
171 | 171 | */ |
172 | - public function isLike (string $pattern) { |
|
172 | + public function isLike(string $pattern) { |
|
173 | 173 | $pattern = $this->db->quote($pattern); |
174 | 174 | return new Predicate("{$this} LIKE {$pattern}"); |
175 | 175 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param null|bool|number|string|Select $arg |
181 | 181 | * @return Predicate |
182 | 182 | */ |
183 | - public function isNot ($arg) { |
|
183 | + public function isNot($arg) { |
|
184 | 184 | return $this->is($arg)->invert(); |
185 | 185 | } |
186 | 186 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param number|string $max |
192 | 192 | * @return Predicate |
193 | 193 | */ |
194 | - public function isNotBetween ($min, $max) { |
|
194 | + public function isNotBetween($min, $max) { |
|
195 | 195 | $min = $this->db->quote($min); |
196 | 196 | $max = $this->db->quote($max); |
197 | 197 | return new Predicate("{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param bool|number|string|array|Select $arg |
204 | 204 | * @return Predicate |
205 | 205 | */ |
206 | - public function isNotEqual ($arg) { |
|
206 | + public function isNotEqual($arg) { |
|
207 | 207 | |
208 | 208 | return Predicate::compare($this, $this->db->quoteMixed($arg), '<>', 'NOT IN'); |
209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param string $pattern |
215 | 215 | * @return Predicate |
216 | 216 | */ |
217 | - public function isNotLike (string $pattern) { |
|
217 | + public function isNotLike(string $pattern) { |
|
218 | 218 | $pattern = $this->db->quote($pattern); |
219 | 219 | return new Predicate("{$this} NOT LIKE {$pattern}"); |
220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $pattern |
226 | 226 | * @return Predicate |
227 | 227 | */ |
228 | - public function isNotRegExp (string $pattern) { |
|
228 | + public function isNotRegExp(string $pattern) { |
|
229 | 229 | $pattern = $this->db->quote($pattern); |
230 | 230 | return new Predicate("{$this} NOT REGEXP {$pattern}"); |
231 | 231 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param string $pattern |
237 | 237 | * @return Predicate |
238 | 238 | */ |
239 | - public function isRegExp (string $pattern) { |
|
239 | + public function isRegExp(string $pattern) { |
|
240 | 240 | $pattern = $this->db->quote($pattern); |
241 | 241 | return new Predicate("{$this} REGEXP {$pattern}"); |
242 | 242 | } |
@@ -56,8 +56,7 @@ |
||
56 | 56 | public function is ($arg): Predicate { |
57 | 57 | if ($arg === null or is_bool($arg)) { |
58 | 58 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
59 | - } |
|
60 | - else { |
|
59 | + } else { |
|
61 | 60 | $arg = $this->db->quote($arg); |
62 | 61 | } |
63 | 62 | switch ($this->db) { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return Text |
19 | 19 | */ |
20 | - public function getHex () { |
|
20 | + public function getHex() { |
|
21 | 21 | return new Text($this->db, "HEX({$this})"); |
22 | 22 | } |
23 | 23 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return Numeric |
30 | 30 | */ |
31 | - public function getLength () { |
|
31 | + public function getLength() { |
|
32 | 32 | switch ($this->db) { |
33 | 33 | case 'sqlite': |
34 | 34 | return new Numeric($this->db, "LENGTH(CAST({$this} AS TEXT))"); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return Text |
44 | 44 | */ |
45 | - public function getLower () { |
|
45 | + public function getLower() { |
|
46 | 46 | return new Text($this->db, "LOWER({$this})"); |
47 | 47 | } |
48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $substring |
55 | 55 | * @return Numeric |
56 | 56 | */ |
57 | - public function getPosition (string $substring) { |
|
57 | + public function getPosition(string $substring) { |
|
58 | 58 | $substring = $this->db->quote($substring); |
59 | 59 | switch ($this->db) { |
60 | 60 | case 'sqlite': |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $replace |
72 | 72 | * @return Text |
73 | 73 | */ |
74 | - public function getReplacement (string $search, string $replace) { |
|
74 | + public function getReplacement(string $search, string $replace) { |
|
75 | 75 | $search = $this->db->quote($search); |
76 | 76 | $replace = $this->db->quote($replace); |
77 | 77 | return new Text($this->db, "REPLACE({$this},{$search},{$replace})"); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return Numeric |
84 | 84 | */ |
85 | - public function getSize () { |
|
85 | + public function getSize() { |
|
86 | 86 | switch ($this->db) { |
87 | 87 | case 'sqlite': |
88 | 88 | return new Numeric($this->db, "LENGTH(CAST({$this} AS BLOB))"); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param int $length |
99 | 99 | * @return Text |
100 | 100 | */ |
101 | - public function getSubstring (int $start, int $length = null) { |
|
101 | + public function getSubstring(int $start, int $length = null) { |
|
102 | 102 | if (isset($length)) { |
103 | 103 | return new Text($this->db, "SUBSTR({$this},{$start},{$length})"); |
104 | 104 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return Text |
112 | 112 | */ |
113 | - public function getUpper () { |
|
113 | + public function getUpper() { |
|
114 | 114 | return new Text($this->db, "UPPER({$this})"); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | \ No newline at end of file |