Passed
Push — master ( 6a4462...5500dc )
by y
01:44
created
src/DB/AbstractTable.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @param DB $db
21 21
      */
22
-    public function __construct (DB $db) {
22
+    public function __construct(DB $db) {
23 23
         $this->db = $db;
24 24
     }
25 25
 
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return string
30 30
      */
31
-    abstract public function __toString ();
31
+    abstract public function __toString();
32 32
 
33 33
     /**
34 34
      * @param string $name
35 35
      * @return bool
36 36
      */
37
-    abstract public function offsetExists ($name): bool;
37
+    abstract public function offsetExists($name): bool;
38 38
 
39 39
     /**
40 40
      * @param string $name
41 41
      * @return Column
42 42
      */
43
-    abstract public function offsetGet ($name);
43
+    abstract public function offsetGet($name);
44 44
 
45 45
     /**
46 46
      * Throws.
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      * @param void $value
50 50
      * @throws Exception
51 51
      */
52
-    final public function offsetSet ($name, $value): void {
52
+    final public function offsetSet($name, $value): void {
53 53
         throw new Exception('Tables are immutable.');
54 54
     }
55 55
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param void $name
60 60
      * @throws Exception
61 61
      */
62
-    final public function offsetUnset ($name): void {
62
+    final public function offsetUnset($name): void {
63 63
         $this->offsetSet($name, null);
64 64
     }
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,8 +196,7 @@
 block discarded – undo
196 196
     public function offsetSet ($class, $access) {
197 197
         if ($access instanceof Record) {
198 198
             $this->setRecord($class, $access);
199
-        }
200
-        else {
199
+        } else {
201 200
             $this->setJunction($class, $access);
202 201
         }
203 202
     }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/DB/SQL/Value.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     use ComparisonTrait;
13 13
     use AggregateTrait;
14 14
 
15
-    public function __construct (DB $db, string $expression) {
15
+    public function __construct(DB $db, string $expression) {
16 16
         $this->db = $db;
17 17
         parent::__construct($expression);
18 18
     }
Please login to merge, or discard this patch.
src/DB/SQL/ExpressionInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,5 +10,5 @@
 block discarded – undo
10 10
     /**
11 11
      * @return string
12 12
      */
13
-    public function __toString ();
13
+    public function __toString();
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/NumericTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      *
20 20
      * @return Numeric
21 21
      */
22
-    public function abs () {
22
+    public function abs() {
23 23
         return new Numeric($this->db, "ABS({$this})");
24 24
     }
25 25
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param number|ValueInterface $arg
30 30
      * @return Numeric
31 31
      */
32
-    public function add ($arg) {
32
+    public function add($arg) {
33 33
         return new Numeric($this->db, "({$this} + {$arg})");
34 34
     }
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @return Numeric
40 40
      */
41
-    public function ceil () {
41
+    public function ceil() {
42 42
         return new Numeric($this->db, "CEIL({$this})");
43 43
     }
44 44
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param number|ValueInterface $arg
49 49
      * @return Numeric
50 50
      */
51
-    public function divide ($arg) {
51
+    public function divide($arg) {
52 52
         return new Numeric($this->db, "({$this} / {$arg})");
53 53
     }
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return Numeric
59 59
      */
60
-    public function floor () {
60
+    public function floor() {
61 61
         return new Numeric($this->db, "FLOOR({$this})");
62 62
     }
63 63
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @return Predicate
68 68
      */
69
-    public function isEven () {
69
+    public function isEven() {
70 70
         return new Predicate("({$this} % 2) = 0");
71 71
     }
72 72
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      *
76 76
      * @return Predicate
77 77
      */
78
-    public function isNegative () {
78
+    public function isNegative() {
79 79
         return new Predicate("{$this} < 0");
80 80
     }
81 81
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      *
85 85
      * @return Predicate
86 86
      */
87
-    public function isOdd () {
87
+    public function isOdd() {
88 88
         return new Predicate("({$this} % 2) <> 0");
89 89
     }
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * @return Predicate
95 95
      */
96
-    public function isPositive () {
96
+    public function isPositive() {
97 97
         return new Predicate("{$this} > 0");
98 98
     }
99 99
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      * @param number|ValueInterface $arg
104 104
      * @return Numeric
105 105
      */
106
-    public function modulo ($arg) {
106
+    public function modulo($arg) {
107 107
         return new Numeric($this->db, "({$this} % {$arg})");
108 108
     }
109 109
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @param number|ValueInterface $arg
114 114
      * @return Numeric
115 115
      */
116
-    public function multiply ($arg) {
116
+    public function multiply($arg) {
117 117
         return new Numeric($this->db, "({$this} * {$arg})");
118 118
     }
119 119
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param number|ValueInterface $exponent
124 124
      * @return Numeric
125 125
      */
126
-    public function pow ($exponent) {
126
+    public function pow($exponent) {
127 127
         return new Numeric($this->db, "POW({$this},{$exponent})");
128 128
     }
129 129
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      * @param int $decimals
134 134
      * @return Numeric
135 135
      */
136
-    public function round (int $decimals = 0) {
136
+    public function round(int $decimals = 0) {
137 137
         return new Numeric($this->db, "ROUND({$this},{$decimals})");
138 138
     }
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      * @param number|ValueInterface $arg
144 144
      * @return Numeric
145 145
      */
146
-    public function subtract ($arg) {
146
+    public function subtract($arg) {
147 147
         return new Numeric($this->db, "({$this} - {$arg})");
148 148
     }
149 149
 }
150 150
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/SQL/Choice.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param string $subject
53 53
      * @param array $values `[when => then]` for the subject.
54 54
      */
55
-    public function __construct (DB $db, string $subject = null, array $values = []) {
55
+    public function __construct(DB $db, string $subject = null, array $values = []) {
56 56
         parent::__construct($db, '');
57 57
         $this->subject = $subject;
58 58
         $this->setValues($values);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     /**
62 62
      * @return string
63 63
      */
64
-    public function __toString () {
64
+    public function __toString() {
65 65
         $sql = 'CASE';
66 66
         if (isset($this->subject)) {
67 67
             $sql .= " {$this->subject}";
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      * @param string|ValueInterface $else
81 81
      * @return $this
82 82
      */
83
-    public function setElse ($else) {
83
+    public function setElse($else) {
84 84
         $this->else = isset($else) ? $this->db->quote($else) : null;
85 85
         return $this;
86 86
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @param string|ValueInterface $then
93 93
      * @return $this
94 94
      */
95
-    public function setValue ($when, $then) {
95
+    public function setValue($when, $then) {
96 96
         $this->values[$this->db->quote($when)] = $this->db->quote($then);
97 97
         return $this;
98 98
     }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      * @param array $values `[when => then]`
104 104
      * @return $this
105 105
      */
106
-    public function setValues (array $values) {
106
+    public function setValues(array $values) {
107 107
         foreach ($values as $when => $then) {
108 108
             $this->setValue($when, $then);
109 109
         }
Please login to merge, or discard this patch.
src/DB/Table.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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}");
Please login to merge, or discard this patch.
src/DB/Select.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/DB/SQL/Predicate.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@
 block discarded – undo
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}");
Please login to merge, or discard this patch.