Passed
Push — master ( ceff3e...1dcf9b )
by y
02:14
created
src/DB/FactoryTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      * @param array $args The first argument must be a {@link DB} instance.
18 18
      * @return static
19 19
      */
20
-    public static function __callStatic (string $ignored, array $args) {
20
+    public static function __callStatic(string $ignored, array $args) {
21 21
         /** @var DB $db */
22 22
         $db = $args[0];
23 23
         unset($args[0]);
Please login to merge, or discard this patch.
src/DB/Select.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      * @param string|Select $table
117 117
      * @param string[] $columns
118 118
      */
119
-    public function __construct (DB $db, $table, array $columns) {
119
+    public function __construct(DB $db, $table, array $columns) {
120 120
         parent::__construct($db);
121 121
         if ($table instanceof Select) {
122 122
             $this->table = $table->toSubquery();
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @param array $args
137 137
      * @return Statement
138 138
      */
139
-    public function __invoke (array $args = []) {
139
+    public function __invoke(array $args = []) {
140 140
         return $this->execute($args);
141 141
     }
142 142
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      *
146 146
      * @return string
147 147
      */
148
-    final public function __toString () {
148
+    final public function __toString() {
149 149
         return $this->alias;
150 150
     }
151 151
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      * @param array $args Execution arguments.
156 156
      * @return int
157 157
      */
158
-    public function count (array $args = []): int {
158
+    public function count(array $args = []): int {
159 159
         $clone = clone $this;
160 160
         $clone->_columns = 'COUNT(*)';
161 161
         $clone->_order = '';
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * @param array $args
169 169
      * @return Statement
170 170
      */
171
-    public function execute (array $args = []) {
171
+    public function execute(array $args = []) {
172 172
         if (empty($args)) {
173 173
             return $this->db->query($this->toSql());
174 174
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      * @param array $args Execution arguments.
184 184
      * @return array
185 185
      */
186
-    public function getAll (array $args = []): array {
186
+    public function getAll(array $args = []): array {
187 187
         return iterator_to_array($this->fetcher->__invoke($this->execute($args)));
188 188
     }
189 189
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @param array $args Execution arguments.
197 197
      * @return Generator
198 198
      */
199
-    public function getEach (array $args = []) {
199
+    public function getEach(array $args = []) {
200 200
         yield from $this->fetcher->__invoke($this->execute($args));
201 201
     }
202 202
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      * @param array $args
209 209
      * @return mixed
210 210
      */
211
-    public function getFirst (array $args = []) {
211
+    public function getFirst(array $args = []) {
212 212
         return $this->getEach($args)->current();
213 213
     }
214 214
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      *
220 220
      * @return Generator
221 221
      */
222
-    public function getIterator () {
222
+    public function getIterator() {
223 223
         yield from $this->getEach();
224 224
     }
225 225
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      * @param string $column
230 230
      * @return $this
231 231
      */
232
-    public function group (string $column) {
232
+    public function group(string $column) {
233 233
         if (!strlen($this->_group)) {
234 234
             $this->_group = " GROUP BY {$column}";
235 235
         }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      * @param string $condition
246 246
      * @return $this
247 247
      */
248
-    public function having (string $condition) {
248
+    public function having(string $condition) {
249 249
         if (!strlen($this->_having)) {
250 250
             $this->_having = " HAVING {$condition}";
251 251
         }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      * @param bool $all
263 263
      * @return $this
264 264
      */
265
-    public function intersect (Select $select, $all = false) {
265
+    public function intersect(Select $select, $all = false) {
266 266
         $select = clone $select;
267 267
         $select->_order = '';
268 268
         $select->_limit = '';
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @return Predicate
282 282
      */
283
-    public function isEmpty () {
283
+    public function isEmpty() {
284 284
         return Predicate::factory($this->db, "NOT EXISTS ({$this->toSql()})");
285 285
     }
286 286
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      *
290 290
      * @return Predicate
291 291
      */
292
-    public function isNotEmpty () {
292
+    public function isNotEmpty() {
293 293
         return Predicate::factory($this->db, "EXISTS ({$this->toSql()})");
294 294
     }
295 295
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      * @param string $type
302 302
      * @return $this
303 303
      */
304
-    public function join ($table, string $condition, string $type = 'INNER') {
304
+    public function join($table, string $condition, string $type = 'INNER') {
305 305
         if ($table instanceof Select) {
306 306
             $table = $table->toSubquery();
307 307
         }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * @param int $offset
317 317
      * @return $this
318 318
      */
319
-    public function limit (int $limit, int $offset = 0) {
319
+    public function limit(int $limit, int $offset = 0) {
320 320
         if ($limit == 0) {
321 321
             $this->_limit = '';
322 322
         }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
      * @param int|string $ref Ordinal or reference name.
336 336
      * @return null|Column
337 337
      */
338
-    public function offsetGet ($ref) {
338
+    public function offsetGet($ref) {
339 339
         if (is_int($ref)) {
340 340
             return current(array_slice($this->refs, $ref, 1)) ?: null;
341 341
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      * @param string $order
349 349
      * @return $this
350 350
      */
351
-    public function order (string $order) {
351
+    public function order(string $order) {
352 352
         if (strlen($order)) {
353 353
             $order = " ORDER BY {$order}";
354 354
         }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     /**
360 360
      * @return Statement
361 361
      */
362
-    public function prepare () {
362
+    public function prepare() {
363 363
         return $this->db->prepare($this->toSql());
364 364
     }
365 365
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      * @param string $alias
368 368
      * @return $this
369 369
      */
370
-    public function setAlias (string $alias) {
370
+    public function setAlias(string $alias) {
371 371
         $this->alias = $alias;
372 372
         foreach ($this->refs as $k => $column) {
373 373
             $this->refs[$k] = $column->setQualifier($alias);
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      * @param string[] $expressions Keyed by alias if applicable.
386 386
      * @return $this
387 387
      */
388
-    public function setColumns (array $expressions) {
388
+    public function setColumns(array $expressions) {
389 389
         $this->refs = [];
390 390
         $_columns = [];
391 391
         foreach ($expressions as $alias => $expr) {
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      * @param Closure $fetcher
411 411
      * @return $this
412 412
      */
413
-    public function setFetcher (Closure $fetcher) {
413
+    public function setFetcher(Closure $fetcher) {
414 414
         $this->fetcher = $fetcher;
415 415
         return $this;
416 416
     }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      *
421 421
      * @return string
422 422
      */
423
-    public function toSql (): string {
423
+    public function toSql(): string {
424 424
         $sql = "SELECT {$this->_columns} FROM {$this->table}";
425 425
         $sql .= $this->_join;
426 426
         $sql .= $this->_where;
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      *
438 438
      * @return string
439 439
      */
440
-    public function toSubquery (): string {
440
+    public function toSubquery(): string {
441 441
         return "({$this->toSql()}) AS {$this->alias}";
442 442
     }
443 443
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      * @param bool $all
449 449
      * @return $this
450 450
      */
451
-    public function union (Select $select, $all = false) {
451
+    public function union(Select $select, $all = false) {
452 452
         $select = clone $select;
453 453
         $select->_order = '';
454 454
         $select->_limit = '';
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
      * @param string $condition
468 468
      * @return $this
469 469
      */
470
-    public function where (string $condition) {
470
+    public function where(string $condition) {
471 471
         if (!strlen($this->_where)) {
472 472
             $this->_where = " WHERE {$condition}";
473 473
         }
Please login to merge, or discard this patch.
src/DB/EAV.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      * @param DB $db
16 16
      * @param string $name
17 17
      */
18
-    public function __construct (DB $db, string $name) {
18
+    public function __construct(DB $db, string $name) {
19 19
         parent::__construct($db, $name, ['entity', 'attribute', 'value']);
20 20
     }
21 21
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      * @param string $attribute
27 27
      * @return bool
28 28
      */
29
-    public function exists (int $id, string $attribute): bool {
29
+    public function exists(int $id, string $attribute): bool {
30 30
         $statement = $this->cache(__FUNCTION__, function() {
31 31
             return $this->select(['COUNT(*) > 0'])->where('entity = ? AND attribute = ?')->prepare();
32 32
         });
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute.
45 45
      * @return Select
46 46
      */
47
-    public function find (array $match) {
47
+    public function find(array $match) {
48 48
         $select = $this->select([$this['entity']]);
49 49
         $prior = $this;
50 50
         foreach ($match as $attribute => $value) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param int $id
67 67
      * @return array `[attribute => value]`
68 68
      */
69
-    public function load (int $id): array {
69
+    public function load(int $id): array {
70 70
         $statement = $this->cache(__FUNCTION__, function() {
71 71
             $select = $this->select(['attribute', 'value']);
72 72
             $select->where('entity = ?');
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @param int[] $ids
83 83
      * @return array[] `[id => attribute => value]
84 84
      */
85
-    public function loadAll (array $ids): array {
85
+    public function loadAll(array $ids): array {
86 86
         if (empty($ids)) {
87 87
             return [];
88 88
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      * @param array $values `[attribute => value]`
108 108
      * @return $this
109 109
      */
110
-    public function save (int $id, array $values) {
110
+    public function save(int $id, array $values) {
111 111
         $this->delete([
112 112
             $this['entity']->isEqual($id),
113 113
             $this['attribute']->isNotEqual(array_keys($values))
Please login to merge, or discard this patch.
src/DB/Junction.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param string $interface
32 32
      * @return Junction
33 33
      */
34
-    public static function fromInterface (DB $db, string $interface) {
34
+    public static function fromInterface(DB $db, string $interface) {
35 35
         try {
36 36
             $ref = new ReflectionClass($interface);
37 37
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param string $table
55 55
      * @param string[] $classes
56 56
      */
57
-    public function __construct (DB $db, string $table, array $classes) {
57
+    public function __construct(DB $db, string $table, array $classes) {
58 58
         parent::__construct($db, $table, array_keys($classes));
59 59
         $this->classes = $classes;
60 60
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param array $match Keyed by junction column.
69 69
      * @return Select
70 70
      */
71
-    public function find (string $key, array $match = []) {
71
+    public function find(string $key, array $match = []) {
72 72
         $record = $this->db->getRecord($this->classes[$key]);
73 73
         $select = $record->select();
74 74
         $select->join($this, $this[$key]->isEqual($record['id']));
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param int[] $ids Keyed by column.
85 85
      * @return int Rows affected.
86 86
      */
87
-    public function link (array $ids): int {
87
+    public function link(array $ids): int {
88 88
         $statement = $this->cache(__FUNCTION__, function() {
89 89
             $columns = implode(',', array_keys($this->columns));
90 90
             $slots = implode(',', SQL::slots(array_keys($this->columns)));
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @param array $ids Keyed by Column
109 109
      * @return int Rows affected
110 110
      */
111
-    public function unlink (array $ids): int {
111
+    public function unlink(array $ids): int {
112 112
         return $this->delete($ids);
113 113
     }
114 114
 }
115 115
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @param string $password
61 61
      * @param array $options
62 62
      */
63
-    public function __construct ($dsn, $username = null, $password = null, array $options = []) {
63
+    public function __construct($dsn, $username = null, $password = null, array $options = []) {
64 64
         $options += [
65 65
             self::ATTR_STATEMENT_CLASS => [Statement::class, [$this]]
66 66
         ];
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      *
84 84
      * @return string
85 85
      */
86
-    final public function __toString () {
86
+    final public function __toString() {
87 87
         return $this->driver;
88 88
     }
89 89
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * @param string $sql
94 94
      * @return int
95 95
      */
96
-    public function exec ($sql): int {
96
+    public function exec($sql): int {
97 97
         $this->logger->__invoke($sql);
98 98
         return parent::exec($sql);
99 99
     }
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
      * @param mixed ...$args
110 110
      * @return mixed
111 111
      */
112
-    public function factory (string $class, ...$args) {
112
+    public function factory(string $class, ...$args) {
113 113
         return new $class($this, ...$args);
114 114
     }
115 115
 
116 116
     /**
117 117
      * @return string
118 118
      */
119
-    final public function getDriver (): string {
119
+    final public function getDriver(): string {
120 120
         return $this->driver;
121 121
     }
122 122
 
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
      * @param string $interface
127 127
      * @return Junction
128 128
      */
129
-    public function getJunction ($interface) {
129
+    public function getJunction($interface) {
130 130
         return $this->junctions[$interface] ??= Junction::fromInterface($this, $interface);
131 131
     }
132 132
 
133 133
     /**
134 134
      * @return Closure
135 135
      */
136
-    public function getLogger () {
136
+    public function getLogger() {
137 137
         return $this->logger;
138 138
     }
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      * @param string|EntityInterface $class
144 144
      * @return Record
145 145
      */
146
-    public function getRecord ($class) {
146
+    public function getRecord($class) {
147 147
         if (is_object($class)) {
148 148
             $class = get_class($class);
149 149
         }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * @param string $name
155 155
      * @return null|Table
156 156
      */
157
-    public function getTable (string $name) {
157
+    public function getTable(string $name) {
158 158
         if (!isset($this->tables[$name])) {
159 159
             if ($this->isSQLite()) {
160 160
                 $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll();
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
     /**
177 177
      * @return bool
178 178
      */
179
-    final public function isMySQL (): bool {
179
+    final public function isMySQL(): bool {
180 180
         return $this->driver === 'mysql';
181 181
     }
182 182
 
183 183
     /**
184 184
      * @return bool
185 185
      */
186
-    final public function isPostgreSQL (): bool {
186
+    final public function isPostgreSQL(): bool {
187 187
         return $this->driver === 'pgsql';
188 188
     }
189 189
 
190 190
     /**
191 191
      * @return bool
192 192
      */
193
-    final public function isSQLite (): bool {
193
+    final public function isSQLite(): bool {
194 194
         return $this->driver === 'sqlite';
195 195
     }
196 196
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      * @param mixed $b
212 212
      * @return Predicate
213 213
      */
214
-    public function match ($a, $b) {
214
+    public function match($a, $b) {
215 215
         if ($b instanceof Closure) {
216 216
             return $b->__invoke($a, $this);
217 217
         }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @param string $table
234 234
      * @return bool
235 235
      */
236
-    final public function offsetExists ($table): bool {
236
+    final public function offsetExists($table): bool {
237 237
         return (bool)$this->getTable($table);
238 238
     }
239 239
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      * @param string $table
244 244
      * @return null|Table
245 245
      */
246
-    final public function offsetGet ($table) {
246
+    final public function offsetGet($table) {
247 247
         return $this->getTable($table);
248 248
     }
249 249
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      * @param $value
253 253
      * @throws LogicException
254 254
      */
255
-    final public function offsetSet ($offset, $value) {
255
+    final public function offsetSet($offset, $value) {
256 256
         throw new LogicException('Raw table access is immutable.');
257 257
     }
258 258
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      * @param $offset
261 261
      * @throws LogicException
262 262
      */
263
-    final public function offsetUnset ($offset) {
263
+    final public function offsetUnset($offset) {
264 264
         throw new LogicException('Raw table access is immutable.');
265 265
     }
266 266
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      * @param array $options
272 272
      * @return Statement
273 273
      */
274
-    public function prepare ($sql, $options = []) {
274
+    public function prepare($sql, $options = []) {
275 275
         $this->logger->__invoke($sql);
276 276
         /** @var Statement $statement */
277 277
         $statement = parent::prepare($sql, $options);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      * @param array $ctorargs Optional.
288 288
      * @return Statement
289 289
      */
290
-    public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
290
+    public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
291 291
         $this->logger->__invoke($sql);
292 292
         /** @var Statement $statement */
293 293
         $statement = parent::query(...func_get_args());
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
      * @param int $type Ignored.
306 306
      * @return string|ExpressionInterface
307 307
      */
308
-    public function quote ($value, $type = self::PARAM_STR) {
308
+    public function quote($value, $type = self::PARAM_STR) {
309 309
         if ($value instanceof ExpressionInterface) {
310 310
             return $value;
311 311
         }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      * @param array $values
326 326
      * @return string[]
327 327
      */
328
-    public function quoteArray (array $values) {
328
+    public function quoteArray(array $values) {
329 329
         return array_map([$this, 'quote'], $values);
330 330
     }
331 331
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
      * @param array $values
336 336
      * @return string
337 337
      */
338
-    public function quoteList (array $values): string {
338
+    public function quoteList(array $values): string {
339 339
         return implode(',', $this->quoteArray($values));
340 340
     }
341 341
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      * @param EntityInterface $entity
346 346
      * @return int ID
347 347
      */
348
-    public function save (EntityInterface $entity): int {
348
+    public function save(EntityInterface $entity): int {
349 349
         return $this->getRecord($entity)->save($entity);
350 350
     }
351 351
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      * @param Junction $junction
355 355
      * @return $this
356 356
      */
357
-    public function setJunction (string $interface, Junction $junction) {
357
+    public function setJunction(string $interface, Junction $junction) {
358 358
         $this->junctions[$interface] = $junction;
359 359
         return $this;
360 360
     }
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
      * @param Closure $logger
364 364
      * @return $this
365 365
      */
366
-    public function setLogger (Closure $logger) {
366
+    public function setLogger(Closure $logger) {
367 367
         $this->logger = $logger;
368 368
         return $this;
369 369
     }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      * @param Record $record
374 374
      * @return $this
375 375
      */
376
-    public function setRecord (string $class, Record $record) {
376
+    public function setRecord(string $class, Record $record) {
377 377
         $this->records[$class] = $record;
378 378
         return $this;
379 379
     }
Please login to merge, or discard this patch.
src/DB/SQL/Num.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
      *
15 15
      * @return Text
16 16
      */
17
-    public function toText () {
17
+    public function toText() {
18 18
         if ($this->db->isSQLite()) {
19 19
             return Text::factory($this->db, "CAST({$this} AS TEXT)");
20 20
         }
Please login to merge, or discard this patch.
src/DB/SQL/Text.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @return Num
16 16
      */
17
-    public function toFloat () {
17
+    public function toFloat() {
18 18
         if ($this->db->isSQLite()) {
19 19
             return Num::factory($this->db, "CAST({$this} AS REAL)");
20 20
         }
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @return Num
28 28
      */
29
-    public function toInt () {
29
+    public function toInt() {
30 30
         if ($this->db->isSQLite()) {
31 31
             return Num::factory($this->db, "CAST({$this} AS INTEGER)");
32 32
         }
Please login to merge, or discard this patch.
src/DB/SQL/TextTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 trait TextTrait {
11 11
 
12
-    abstract public function __toString ();
12
+    abstract public function __toString();
13 13
 
14 14
     /**
15 15
      * @var DB
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @return Text
21 21
      */
22
-    public function getHex () {
22
+    public function getHex() {
23 23
         return Text::factory($this->db, "HEX({$this})");
24 24
     }
25 25
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return Num
32 32
      */
33
-    public function getLength () {
33
+    public function getLength() {
34 34
         if ($this->db->isSQLite()) {
35 35
             return Num::factory($this->db, "LENGTH(CAST({$this} AS TEXT))");
36 36
         }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @return Text
44 44
      */
45
-    public function getLower () {
45
+    public function getLower() {
46 46
         return Text::factory($this->db, "LOWER({$this})");
47 47
     }
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param string $substring
55 55
      * @return Num
56 56
      */
57
-    public function getPosition (string $substring) {
57
+    public function getPosition(string $substring) {
58 58
         $substring = $this->db->quote($substring);
59 59
         if ($this->db->isSQLite()) {
60 60
             return Num::factory($this->db, "INSTR({$this},{$substring})");
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param string $replace
70 70
      * @return Text
71 71
      */
72
-    public function getReplacement (string $search, string $replace) {
72
+    public function getReplacement(string $search, string $replace) {
73 73
         $search = $this->db->quote($search);
74 74
         $replace = $this->db->quote($replace);
75 75
         return Text::factory($this->db, "REPLACE({$this},{$search},{$replace})");
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return Num
82 82
      */
83
-    public function getSize () {
83
+    public function getSize() {
84 84
         if ($this->db->isSQLite()) {
85 85
             return Num::factory($this->db, "LENGTH(CAST({$this} AS BLOB))");
86 86
         }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      * @param null|int $length
95 95
      * @return Text
96 96
      */
97
-    public function getSubstring (int $start, int $length = null) {
97
+    public function getSubstring(int $start, int $length = null) {
98 98
         if (isset($length)) {
99 99
             return Text::factory($this->db, "SUBSTR({$this},{$start},{$length})");
100 100
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @return Text
108 108
      */
109
-    public function getUpper () {
109
+    public function getUpper() {
110 110
         return Text::factory($this->db, "UPPER({$this})");
111 111
     }
112 112
 }
113 113
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/DateTimeTrait.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 trait DateTimeTrait {
14 14
 
15
-    abstract public function __toString ();
15
+    abstract public function __toString();
16 16
 
17 17
     /**
18 18
      * @var DB
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      *
25 25
      * @return Text
26 26
      */
27
-    public function getDate () {
27
+    public function getDate() {
28 28
         return Text::factory($this->db, $this->getDateTimeFormat('%Y-%m-%d'));
29 29
     }
30 30
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @return Text
35 35
      */
36
-    public function getDateTime () {
36
+    public function getDateTime() {
37 37
         return Text::factory($this->db, $this->getDateTimeFormat([
38 38
             'mysql' => '%Y-%m-%d %H:%i:%S',
39 39
             'sqlite' => '%Y-%m-%d %H:%M:%S'
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param string|string[] $format Format, or formats keyed by driver name.
47 47
      * @return Text
48 48
      */
49
-    public function getDateTimeFormat ($format) {
49
+    public function getDateTimeFormat($format) {
50 50
         if (is_array($format)) {
51 51
             $format = $format[$this->db->getDriver()];
52 52
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return Num
64 64
      */
65
-    public function getDay () {
65
+    public function getDay() {
66 66
         return Num::factory($this->db, $this->getDateTimeFormat('%d'));
67 67
     }
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return Num
73 73
      */
74
-    public function getDayOfWeek () {
74
+    public function getDayOfWeek() {
75 75
         return Num::factory($this->db, $this->getDateTimeFormat('%w'));
76 76
     }
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return Num
82 82
      */
83
-    public function getDayOfYear () {
83
+    public function getDayOfYear() {
84 84
         return Num::factory($this->db, $this->getDateTimeFormat('%j'));
85 85
     }
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return Num
91 91
      */
92
-    public function getHours () {
92
+    public function getHours() {
93 93
         return Num::factory($this->db, $this->getDateTimeFormat('%H'));
94 94
     }
95 95
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      *
99 99
      * @return Num
100 100
      */
101
-    public function getMinutes () {
101
+    public function getMinutes() {
102 102
         return Num::factory($this->db, $this->getDateTimeFormat([
103 103
             'mysql' => '%i',
104 104
             'sqlite' => '%M'
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @return Num
112 112
      */
113
-    public function getMonth () {
113
+    public function getMonth() {
114 114
         return Num::factory($this->db, $this->getDateTimeFormat('%m'));
115 115
     }
116 116
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      *
120 120
      * @return Num
121 121
      */
122
-    public function getSeconds () {
122
+    public function getSeconds() {
123 123
         return Num::factory($this->db, $this->getDateTimeFormat('%S'));
124 124
     }
125 125
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      *
129 129
      * @return Text
130 130
      */
131
-    public function getTime () {
131
+    public function getTime() {
132 132
         return Text::factory($this->db, $this->getDateTimeFormat([
133 133
             'mysql' => '%H:%i:%S',
134 134
             'sqlite' => '%H:%M:%S'
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      *
141 141
      * @return Num
142 142
      */
143
-    public function getTimestamp () {
143
+    public function getTimestamp() {
144 144
         if ($this->db->isSQLite()) {
145 145
             return Num::factory($this->db, "STRFTIME('%s',{$this})");
146 146
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return Num
154 154
      */
155
-    public function getWeekOfYear () {
155
+    public function getWeekOfYear() {
156 156
         return Num::factory($this->db, $this->getDateTimeFormat([
157 157
             'mysql' => '%U',
158 158
             'sqlite' => '%W'
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      *
165 165
      * @return Num
166 166
      */
167
-    public function getYear () {
167
+    public function getYear() {
168 168
         return Num::factory($this->db, $this->getDateTimeFormat('%Y'));
169 169
     }
170 170
 }
171 171
\ No newline at end of file
Please login to merge, or discard this patch.