Passed
Push — master ( ed974e...305c34 )
by y
01:30
created
src/DB/SQL/Numeric.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->getDriver() === 'sqlite') {
19 19
             return new Text($this->db, "CAST({$this} AS TEXT)");
20 20
         }
Please login to merge, or discard this patch.
src/DB.php 1 patch
Spacing   +21 added lines, -21 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);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string $sql
75 75
      * @return int
76 76
      */
77
-    public function exec ($sql): int {
77
+    public function exec($sql): int {
78 78
         $this->logger->__invoke($sql);
79 79
         return parent::exec($sql);
80 80
     }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * @return string
84 84
      */
85
-    final public function getDriver (): string {
85
+    final public function getDriver(): string {
86 86
         return $this->driver;
87 87
     }
88 88
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @param string $interface
93 93
      * @return Junction
94 94
      */
95
-    public function getJunction ($interface) {
95
+    public function getJunction($interface) {
96 96
         if (!isset($this->junctions[$interface])) {
97 97
             $this->junctions[$interface] = Junction::fromInterface($this, $interface);
98 98
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     /**
103 103
      * @return Closure
104 104
      */
105
-    public function getLogger () {
105
+    public function getLogger() {
106 106
         return $this->logger;
107 107
     }
108 108
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      * @param string|EntityInterface $class
113 113
      * @return Record
114 114
      */
115
-    public function getRecord ($class) {
115
+    public function getRecord($class) {
116 116
         $name = $class;
117 117
         if (is_object($name)) {
118 118
             $name = get_class($name);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      * @param mixed $b
138 138
      * @return string
139 139
      */
140
-    public function match ($a, $b) {
140
+    public function match($a, $b) {
141 141
         if ($b instanceof Closure) {
142 142
             if (!$a instanceof Column) {
143 143
                 $a = new Column($this, $a);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param array $match
164 164
      * @return string[]
165 165
      */
166
-    public function matchArray (array $match) {
166
+    public function matchArray(array $match) {
167 167
         return array_map([$this, 'match'], array_keys($match), $match);
168 168
     }
169 169
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @param string $class Class or interface name.
172 172
      * @return bool
173 173
      */
174
-    public function offsetExists ($class): bool {
174
+    public function offsetExists($class): bool {
175 175
         return (bool)$this->offsetGet($class);
176 176
     }
177 177
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @param string $class Class or interface name.
180 180
      * @return null|Record|Junction
181 181
      */
182
-    public function offsetGet ($class) {
182
+    public function offsetGet($class) {
183 183
         if (class_exists($class)) {
184 184
             return $this->getRecord($class);
185 185
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      * @param string $class Class or interface name.
194 194
      * @param Record|Junction $access
195 195
      */
196
-    public function offsetSet ($class, $access) {
196
+    public function offsetSet($class, $access) {
197 197
         if ($access instanceof Record) {
198 198
             $this->setRecord($class, $access);
199 199
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     /**
206 206
      * @param string $class Class or interface name.
207 207
      */
208
-    public function offsetUnset ($class) {
208
+    public function offsetUnset($class) {
209 209
         unset($this->records[$class]);
210 210
         unset($this->junctions[$class]);
211 211
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      * @param array $options
218 218
      * @return Statement
219 219
      */
220
-    public function prepare ($sql, $options = []) {
220
+    public function prepare($sql, $options = []) {
221 221
         $this->logger->__invoke($sql);
222 222
         /** @var Statement $statement */
223 223
         $statement = parent::prepare($sql, $options);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @param array $ctorargs
234 234
      * @return Statement
235 235
      */
236
-    public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
236
+    public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
237 237
         $this->logger->__invoke($sql);
238 238
         /** @var Statement $statement */
239 239
         $statement = parent::query(...func_get_args());
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      * @param int $type Ignored.
253 253
      * @return string
254 254
      */
255
-    public function quote ($value, $type = null) {
255
+    public function quote($value, $type = null) {
256 256
         if ($value instanceof ExpressionInterface) {
257 257
             return $value;
258 258
         }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      * @param array $values
273 273
      * @return string[]
274 274
      */
275
-    public function quoteArray (array $values): array {
275
+    public function quoteArray(array $values): array {
276 276
         return array_map([$this, 'quote'], $values);
277 277
     }
278 278
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @param mixed $value
283 283
      * @return string|string[]
284 284
      */
285
-    public function quoteMixed ($value) {
285
+    public function quoteMixed($value) {
286 286
         if (is_array($value)) {
287 287
             return $this->quoteArray($value);
288 288
         }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      * @param EntityInterface $entity
296 296
      * @return int ID
297 297
      */
298
-    public function save (EntityInterface $entity): int {
298
+    public function save(EntityInterface $entity): int {
299 299
         return $this->getRecord($entity)->save($entity);
300 300
     }
301 301
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      * @param Junction $junction
305 305
      * @return $this
306 306
      */
307
-    public function setJunction (string $interface, Junction $junction) {
307
+    public function setJunction(string $interface, Junction $junction) {
308 308
         $this->junctions[$interface] = $junction;
309 309
         return $this;
310 310
     }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
      * @param Closure $logger
314 314
      * @return $this
315 315
      */
316
-    public function setLogger (Closure $logger) {
316
+    public function setLogger(Closure $logger) {
317 317
         $this->logger = $logger;
318 318
         return $this;
319 319
     }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      * @param Record $record
324 324
      * @return $this
325 325
      */
326
-    public function setRecord (string $class, Record $record) {
326
+    public function setRecord(string $class, Record $record) {
327 327
         $this->records[$class] = $record;
328 328
         return $this;
329 329
     }
Please login to merge, or discard this patch.
src/DB/SQL/ComparisonTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      * @param null|bool|string|Select $arg
27 27
      * @return Predicate
28 28
      */
29
-    public function is ($arg): Predicate {
29
+    public function is($arg): Predicate {
30 30
         if ($arg === null or is_bool($arg)) {
31 31
             $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg];
32 32
         }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param number|string $max
45 45
      * @return Predicate
46 46
      */
47
-    public function isBetween ($min, $max) {
47
+    public function isBetween($min, $max) {
48 48
         return new Predicate("{$this} BETWEEN {$this->db->quote($min)} AND {$this->db->quote($max)}");
49 49
     }
50 50
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param string|array|Select $arg
55 55
      * @return Predicate
56 56
      */
57
-    public function isEqual ($arg) {
57
+    public function isEqual($arg) {
58 58
         return Predicate::compare($this, $this->db->quoteMixed($arg));
59 59
     }
60 60
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @param string|Select $arg
65 65
      * @return Predicate
66 66
      */
67
-    public function isGreater ($arg) {
67
+    public function isGreater($arg) {
68 68
         return Predicate::compare($this, $this->db->quote($arg), '>', 'ALL');
69 69
     }
70 70
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string|Select $arg
75 75
      * @return Predicate
76 76
      */
77
-    public function isGreaterOrEqual ($arg) {
77
+    public function isGreaterOrEqual($arg) {
78 78
         return Predicate::compare($this, $this->db->quote($arg), '>=', 'ALL');
79 79
     }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param string|Select $arg
85 85
      * @return Predicate
86 86
      */
87
-    public function isLess ($arg) {
87
+    public function isLess($arg) {
88 88
         return Predicate::compare($this, $this->db->quote($arg), '<', 'ALL');
89 89
     }
90 90
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      * @param string|Select $arg
95 95
      * @return Predicate
96 96
      */
97
-    public function isLessOrEqual ($arg) {
97
+    public function isLessOrEqual($arg) {
98 98
         return Predicate::compare($this, $this->db->quote($arg), '<=', 'ALL');
99 99
     }
100 100
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param string $pattern
105 105
      * @return Predicate
106 106
      */
107
-    public function isLike (string $pattern) {
107
+    public function isLike(string $pattern) {
108 108
         return Predicate::compare($this, $this->db->quote($pattern), 'LIKE');
109 109
     }
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @param null|bool|string|Select $arg
115 115
      * @return Predicate
116 116
      */
117
-    public function isNot ($arg) {
117
+    public function isNot($arg) {
118 118
         return $this->is($arg)->invert();
119 119
     }
120 120
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @param number|string $max
126 126
      * @return Predicate
127 127
      */
128
-    public function isNotBetween ($min, $max) {
128
+    public function isNotBetween($min, $max) {
129 129
         return new Predicate("{$this} NOT BETWEEN {$this->db->quote($min)} AND {$this->db->quote($max)}");
130 130
     }
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @param string|array|Select $arg
136 136
      * @return Predicate
137 137
      */
138
-    public function isNotEqual ($arg) {
138
+    public function isNotEqual($arg) {
139 139
         return Predicate::compare($this, $this->db->quoteMixed($arg), '<>', 'ALL', 'NOT IN');
140 140
     }
141 141
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @param string $pattern
146 146
      * @return Predicate
147 147
      */
148
-    public function isNotLike (string $pattern) {
148
+    public function isNotLike(string $pattern) {
149 149
         return Predicate::compare($this, $this->db->quote($pattern), 'NOT LIKE');
150 150
     }
151 151
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      * @param string $pattern
156 156
      * @return Predicate
157 157
      */
158
-    public function isNotRegExp (string $pattern) {
158
+    public function isNotRegExp(string $pattern) {
159 159
         return Predicate::compare($this, $this->db->quote($pattern), 'NOT REGEXP');
160 160
     }
161 161
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param string $pattern
166 166
      * @return Predicate
167 167
      */
168
-    public function isRegExp (string $pattern) {
168
+    public function isRegExp(string $pattern) {
169 169
         return Predicate::compare($this, $this->db->quote($pattern), 'REGEXP');
170 170
     }
171 171
 }
172 172
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Select.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string|Select $table
75 75
      * @param string[] $columns
76 76
      */
77
-    public function __construct (DB $db, $table, array $columns) {
77
+    public function __construct(DB $db, $table, array $columns) {
78 78
         parent::__construct($db);
79 79
         if ($table instanceof Select) {
80 80
             $table = $table->toSubquery();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      * Gives the clone a new alias.
98 98
      */
99
-    public function __clone () {
99
+    public function __clone() {
100 100
         $this->alias = uniqid('_') . "__{$this->table}";
101 101
     }
102 102
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param array $args
105 105
      * @return Statement
106 106
      */
107
-    public function __invoke (array $args = []) {
107
+    public function __invoke(array $args = []) {
108 108
         return $this->execute($args);
109 109
     }
110 110
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return string
115 115
      */
116
-    final public function __toString () {
116
+    final public function __toString() {
117 117
         return $this->alias;
118 118
     }
119 119
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param array $args Execution arguments.
124 124
      * @return int
125 125
      */
126
-    public function count (array $args = []): int {
126
+    public function count(array $args = []): int {
127 127
         $clone = clone $this;
128 128
         $clone->_columns = 'COUNT(*)';
129 129
         return (int)$clone->execute($args)->fetchColumn();
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @param array $args
136 136
      * @return Statement
137 137
      */
138
-    public function execute (array $args = []) {
138
+    public function execute(array $args = []) {
139 139
         if (empty($args)) {
140 140
             return $this->db->query($this->toSql());
141 141
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @param array $args Execution arguments.
151 151
      * @return array
152 152
      */
153
-    public function fetchAll (array $args = []): array {
153
+    public function fetchAll(array $args = []): array {
154 154
         return iterator_to_array($this->fetcher->__invoke($this->execute($args)));
155 155
     }
156 156
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param array $args Execution arguments.
164 164
      * @return Generator
165 165
      */
166
-    public function fetchEach (array $args = []) {
166
+    public function fetchEach(array $args = []) {
167 167
         yield from $this->fetcher->__invoke($this->execute($args));
168 168
     }
169 169
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @return Generator
176 176
      */
177
-    public function getIterator () {
177
+    public function getIterator() {
178 178
         yield from $this->fetchEach();
179 179
     }
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      * @param string $column
185 185
      * @return $this
186 186
      */
187
-    public function group (string $column) {
187
+    public function group(string $column) {
188 188
         if (!strlen($this->_group)) {
189 189
             $this->_group = " GROUP BY {$column}";
190 190
         }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      * @param string $condition
201 201
      * @return $this
202 202
      */
203
-    public function having (string $condition) {
203
+    public function having(string $condition) {
204 204
         if (!strlen($this->_having)) {
205 205
             $this->_having = " HAVING {$condition}";
206 206
         }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      *
216 216
      * @return Predicate
217 217
      */
218
-    public function isEmpty () {
218
+    public function isEmpty() {
219 219
         return new Predicate("NOT EXISTS ({$this->toSql()}");
220 220
     }
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      *
225 225
      * @return Predicate
226 226
      */
227
-    public function isNotEmpty () {
227
+    public function isNotEmpty() {
228 228
         return new Predicate("EXISTS ({$this->toSql()})");
229 229
     }
230 230
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      * @param string $type
237 237
      * @return $this
238 238
      */
239
-    public function join ($table, string $condition, string $type = 'INNER') {
239
+    public function join($table, string $condition, string $type = 'INNER') {
240 240
         if ($table instanceof Select) {
241 241
             $table = $table->toSubquery();
242 242
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @param int $offset
252 252
      * @return $this
253 253
      */
254
-    public function limit (int $limit, int $offset = 0) {
254
+    public function limit(int $limit, int $offset = 0) {
255 255
         if ($limit == 0) {
256 256
             $this->_limit = '';
257 257
         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      * @param string $name Name or alias if used.
271 271
      * @return bool
272 272
      */
273
-    public function offsetExists ($name): bool {
273
+    public function offsetExists($name): bool {
274 274
         return true;
275 275
     }
276 276
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      * @param string $name Name, or alias if used.
281 281
      * @return Column
282 282
      */
283
-    public function offsetGet ($name) {
283
+    public function offsetGet($name) {
284 284
         return new Column($this->db, $name, $this->alias);
285 285
     }
286 286
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @param string $order
291 291
      * @return $this
292 292
      */
293
-    public function order (string $order) {
293
+    public function order(string $order) {
294 294
         if (strlen($order)) {
295 295
             $order = " ORDER BY {$order}";
296 296
         }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     /**
302 302
      * @return Statement
303 303
      */
304
-    public function prepare () {
304
+    public function prepare() {
305 305
         return $this->db->prepare($this->toSql());
306 306
     }
307 307
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      * @param Closure $fetcher
310 310
      * @return $this
311 311
      */
312
-    public function setFetcher (Closure $fetcher) {
312
+    public function setFetcher(Closure $fetcher) {
313 313
         $this->fetcher = $fetcher;
314 314
         return $this;
315 315
     }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     /**
318 318
      * @return string
319 319
      */
320
-    public function toSql (): string {
320
+    public function toSql(): string {
321 321
         $sql = "SELECT {$this->_columns} FROM {$this->table}";
322 322
         $sql .= $this->_join;
323 323
         $sql .= $this->_where;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
      *
334 334
      * @return string
335 335
      */
336
-    public function toSubquery (): string {
336
+    public function toSubquery(): string {
337 337
         return "({$this->toSql()}) AS {$this->alias}";
338 338
     }
339 339
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
      * @param string $condition
344 344
      * @return $this
345 345
      */
346
-    public function where (string $condition) {
346
+    public function where(string $condition) {
347 347
         if (!strlen($this->_where)) {
348 348
             $this->_where = " WHERE {$condition}";
349 349
         }
Please login to merge, or discard this patch.