Passed
Push — master ( ba71ff...07eab0 )
by y
01:13
created
src/DB/EntityInterface.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 int
12 12
      */
13
-    public function getId (): int;
13
+    public function getId(): int;
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Select.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -276,14 +276,12 @@  discard block
 block discarded – undo
276 276
             if ($column instanceof Column) {
277 277
                 $name = $column->getName();
278 278
                 $column = (string)$column;
279
-            }
280
-            else {
279
+            } else {
281 280
                 $name = $column = (string)$column;
282 281
             }
283 282
             if (is_string($alias) and $alias !== $name) {
284 283
                 $this->columns[$alias] = $column;
285
-            }
286
-            else {
284
+            } else {
287 285
                 $this->columns[$column] = $column;
288 286
             }
289 287
         }
@@ -307,8 +305,7 @@  discard block
 block discarded – undo
307 305
         foreach ($this->columns as $alias => $column) {
308 306
             if ($alias !== $column) {
309 307
                 $columns[] = "{$column} AS {$alias}";
310
-            }
311
-            else {
308
+            } else {
312 309
                 $columns[] = "{$column}";
313 310
             }
314 311
         }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param string|Select $table
76 76
      * @param array $columns Strings or {@link Column}. Keys are used for aliasing.
77 77
      */
78
-    public function __construct (DB $db, $table, array $columns) {
78
+    public function __construct(DB $db, $table, array $columns) {
79 79
         parent::__construct($db);
80 80
         if ($table instanceof Select) {
81 81
             $table = $table->toSubquery();
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     /**
92 92
      * Gives the clone a new alias.
93 93
      */
94
-    public function __clone () {
94
+    public function __clone() {
95 95
         $this->alias = uniqid('_') . "__{$this->table}";
96 96
     }
97 97
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      * @param array $args
100 100
      * @return PDOStatement
101 101
      */
102
-    public function __invoke (array $args = []) {
102
+    public function __invoke(array $args = []) {
103 103
         return $this->execute($args);
104 104
     }
105 105
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      *
109 109
      * @return string
110 110
      */
111
-    public function __toString (): string {
111
+    public function __toString(): string {
112 112
         return $this->alias;
113 113
     }
114 114
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      * @param array $args Execution arguments.
119 119
      * @return int
120 120
      */
121
-    public function count (array $args = []): int {
121
+    public function count(array $args = []): int {
122 122
         $clone = clone $this;
123 123
         $clone->setColumns(['COUNT(*)']);
124 124
         return (int)$clone->execute($args)->fetchColumn();
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      * @param array $args
131 131
      * @return PDOStatement
132 132
      */
133
-    public function execute (array $args = []): PDOStatement {
133
+    public function execute(array $args = []): PDOStatement {
134 134
         $statement = $this->prepare();
135 135
         $statement->execute($args);
136 136
         return $statement;
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
      * @param array $args Execution arguments.
145 145
      * @return array
146 146
      */
147
-    public function fetchAll (array $args = []): array {
147
+    public function fetchAll(array $args = []): array {
148 148
         return $this->fetcher->__invoke($this->execute($args));
149 149
     }
150 150
 
151 151
     /**
152 152
      * @return string
153 153
      */
154
-    final public function getAlias (): string {
154
+    final public function getAlias(): string {
155 155
         return $this->alias;
156 156
     }
157 157
 
158 158
     /**
159 159
      * @return Closure
160 160
      */
161
-    public function getFetcher (): Closure {
161
+    public function getFetcher(): Closure {
162 162
         return $this->fetcher;
163 163
     }
164 164
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      *
170 170
      * @return ArrayIterator
171 171
      */
172
-    public function getIterator () {
172
+    public function getIterator() {
173 173
         return new ArrayIterator($this->fetchAll());
174 174
     }
175 175
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @param string $column
180 180
      * @return $this
181 181
      */
182
-    public function group ($column) {
182
+    public function group($column) {
183 183
         $this->_group[] = $column;
184 184
         return $this;
185 185
     }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param string $condition
191 191
      * @return $this
192 192
      */
193
-    public function having ($condition) {
193
+    public function having($condition) {
194 194
         $this->_having[] = $condition;
195 195
         return $this;
196 196
     }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * @param string $type
204 204
      * @return $this
205 205
      */
206
-    public function join ($table, $condition, $type = 'INNER') {
206
+    public function join($table, $condition, $type = 'INNER') {
207 207
         if ($table instanceof Select) {
208 208
             $table = $table->toSubquery();
209 209
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @param int $offset
219 219
      * @return $this
220 220
      */
221
-    public function limit ($limit, $offset = 0) {
221
+    public function limit($limit, $offset = 0) {
222 222
         $this->_limit = " LIMIT {$limit}";
223 223
         if ($offset) {
224 224
             $this->_limit .= " OFFSET {$offset}";
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @param string $name Name or alias if used.
233 233
      * @return bool
234 234
      */
235
-    public function offsetExists ($name): bool {
235
+    public function offsetExists($name): bool {
236 236
         return isset($this->columns[$name]);
237 237
     }
238 238
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      * @param string $name Name or alias if used.
243 243
      * @return Column
244 244
      */
245
-    public function offsetGet ($name): Column {
245
+    public function offsetGet($name): Column {
246 246
         return new Column($this->db, $name, $this->alias);
247 247
     }
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      * @param string $order
253 253
      * @return $this
254 254
      */
255
-    public function order ($order) {
255
+    public function order($order) {
256 256
         $this->_order = " ORDER BY {$order}";
257 257
         return $this;
258 258
     }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     /**
261 261
      * @return PDOStatement
262 262
      */
263
-    public function prepare (): PDOStatement {
263
+    public function prepare(): PDOStatement {
264 264
         return $this->db->prepare($this->toSql());
265 265
     }
266 266
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      * @param array $columns Strings or {@link Column}. Keys are used for aliasing.
271 271
      * @return $this
272 272
      */
273
-    public function setColumns (array $columns) {
273
+    public function setColumns(array $columns) {
274 274
         $this->columns = [];
275 275
         foreach ($columns as $alias => $column) {
276 276
             if ($column instanceof Column) {
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      * @param Closure $fetcher
295 295
      * @return $this
296 296
      */
297
-    public function setFetcher (Closure $fetcher) {
297
+    public function setFetcher(Closure $fetcher) {
298 298
         $this->fetcher = $fetcher;
299 299
         return $this;
300 300
     }
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     /**
303 303
      * @return string
304 304
      */
305
-    public function toSql (): string {
305
+    public function toSql(): string {
306 306
         $columns = [];
307 307
         foreach ($this->columns as $alias => $column) {
308 308
             if ($alias !== $column) {
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      *
337 337
      * @return string
338 338
      */
339
-    public function toSubquery (): string {
339
+    public function toSubquery(): string {
340 340
         return "({$this->toSql()}) AS {$this->getAlias()}";
341 341
     }
342 342
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      * @param string $condition
347 347
      * @return $this
348 348
      */
349
-    public function where ($condition) {
349
+    public function where($condition) {
350 350
         $this->_where[] = $condition;
351 351
         return $this;
352 352
     }
Please login to merge, or discard this patch.
src/DB/AbstractAccess.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * @param DB $db
28 28
      */
29
-    public function __construct (DB $db) {
29
+    public function __construct(DB $db) {
30 30
         $this->db = $db;
31 31
     }
32 32
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param Closure $prepare `():PDOStatement`
38 38
      * @return PDOStatement
39 39
      */
40
-    protected function cache (string $key, Closure $prepare): PDOStatement {
40
+    protected function cache(string $key, Closure $prepare): PDOStatement {
41 41
         return $this->_cache[$key] ?? $this->_cache[$key] = $prepare->__invoke();
42 42
     }
43 43
 
Please login to merge, or discard this patch.
src/DB/Record.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @param DB $db
64 64
      * @param string $class
65 65
      */
66
-    public function __construct (DB $db, string $class) {
66
+    public function __construct(DB $db, string $class) {
67 67
         $this->db = $db;
68 68
         $this->class = $class;
69 69
         try {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @param PDOStatement $statement
110 110
      * @return EntityInterface[] Enumerated
111 111
      */
112
-    public function fetchAll (PDOStatement $statement): array {
112
+    public function fetchAll(PDOStatement $statement): array {
113 113
         $entities = [];
114 114
         foreach ($statement->fetchAll() as $row) {
115 115
             $clone = clone $this->proto;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      * @param array[] $eavMatch Additional `[eav property => attribute => mixed]`
130 130
      * @return Select
131 131
      */
132
-    public function find (array $match, array $eavMatch = []): Select {
132
+    public function find(array $match, array $eavMatch = []): Select {
133 133
         $select = $this->select();
134 134
         foreach ($match as $column => $value) {
135 135
             $select->where($this->db->match($column, $value));
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     /**
145 145
      * @return string
146 146
      */
147
-    final public function getClass (): string {
147
+    final public function getClass(): string {
148 148
         return $this->class;
149 149
     }
150 150
 
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
      * @param string $property
153 153
      * @return EAV
154 154
      */
155
-    final public function getEav ($property): EAV {
155
+    final public function getEav($property): EAV {
156 156
         return $this->eav[$property];
157 157
     }
158 158
 
159 159
     /**
160 160
      * @return EntityInterface
161 161
      */
162
-    public function getProto (): EntityInterface {
162
+    public function getProto(): EntityInterface {
163 163
         return $this->proto;
164 164
     }
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @param EntityInterface $entity
168 168
      * @return array
169 169
      */
170
-    protected function getValues (EntityInterface $entity): array {
170
+    protected function getValues(EntityInterface $entity): array {
171 171
         $values = [];
172 172
         foreach (array_keys($this->columns) as $name) {
173 173
             $values[$name] = $this->properties[$name]->getValue($entity);
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param int $id
182 182
      * @return null|EntityInterface
183 183
      */
184
-    public function load ($id): ?EntityInterface {
184
+    public function load($id): ?EntityInterface {
185 185
         $load = $this->cache(__FUNCTION__, function() {
186 186
             return $this->select()->where('id=:id')->prepare();
187 187
         });
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      *
201 201
      * @param EntityInterface[] $entities
202 202
      */
203
-    protected function loadEav (array $entities): void {
203
+    protected function loadEav(array $entities): void {
204 204
         $ids = array_keys($entities);
205 205
         foreach ($this->eav as $name => $eav) {
206 206
             foreach ($eav->loadAll($ids) as $id => $values) {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      * @param EntityInterface $entity
216 216
      * @return int ID
217 217
      */
218
-    public function save (EntityInterface $entity): int {
218
+    public function save(EntityInterface $entity): int {
219 219
         if (!$entity->getId()) {
220 220
             $this->saveInsert($entity);
221 221
         }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     /**
230 230
      * @param EntityInterface $entity
231 231
      */
232
-    protected function saveEav (EntityInterface $entity): void {
232
+    protected function saveEav(EntityInterface $entity): void {
233 233
         $id = $entity->getId();
234 234
         foreach ($this->eav as $name => $eav) {
235 235
             $values = $this->properties[$name]->getValue($entity);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      *
245 245
      * @param EntityInterface $entity
246 246
      */
247
-    protected function saveInsert (EntityInterface $entity): void {
247
+    protected function saveInsert(EntityInterface $entity): void {
248 248
         $insert = $this->cache(__FUNCTION__, function() {
249 249
             $slots = SQL::slots(array_keys($this->columns));
250 250
             unset($slots['id']);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      *
264 264
      * @param EntityInterface $entity
265 265
      */
266
-    protected function saveUpdate (EntityInterface $entity): void {
266
+    protected function saveUpdate(EntityInterface $entity): void {
267 267
         $this->cache(__FUNCTION__, function() {
268 268
             $slots = SQL::slots(array_keys($this->columns));
269 269
             unset($slots['id']);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      * @param array $columns Defaults to all columns.
279 279
      * @return Select
280 280
      */
281
-    public function select (array $columns = []): Select {
281
+    public function select(array $columns = []): Select {
282 282
         $select = parent::select($columns);
283 283
         $select->setFetcher(function(PDOStatement $statement) {
284 284
             return $this->fetchAll($statement);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @param EntityInterface $proto
291 291
      * @return $this
292 292
      */
293
-    public function setProto (EntityInterface $proto) {
293
+    public function setProto(EntityInterface $proto) {
294 294
         $this->proto = $proto;
295 295
         return $this;
296 296
     }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      * @param EntityInterface $entity
300 300
      * @param array $values
301 301
      */
302
-    protected function setValues (EntityInterface $entity, array $values): void {
302
+    protected function setValues(EntityInterface $entity, array $values): void {
303 303
         foreach ($values as $name => $value) {
304 304
             settype($value, $this->types[$name]);
305 305
             $this->properties[$name]->setValue($entity, $value);
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@  discard block
 block discarded – undo
68 68
         $this->class = $class;
69 69
         try {
70 70
             $class = new ReflectionClass($class);
71
-        }
72
-        catch (ReflectionException $exception) {
71
+        } catch (ReflectionException $exception) {
73 72
             throw new LogicException('Unexpected ReflectionException', 0, $exception);
74 73
         }
75 74
         $this->proto = $class->newInstanceWithoutConstructor();
@@ -88,8 +87,7 @@  discard block
 block discarded – undo
88 87
                 if (preg_match('/@var\s+(?<type>\S+)/', $doc, $var)) {
89 88
                     $types[$name] = $var['type'];
90 89
                 }
91
-            }
92
-            elseif (preg_match('/@eav\s+(?<table>\S+)/', $doc, $match)) {
90
+            } elseif (preg_match('/@eav\s+(?<table>\S+)/', $doc, $match)) {
93 91
                 $eav[$name] = $match['table'];
94 92
                 $this->properties[$name] = $property;
95 93
             }
@@ -218,8 +216,7 @@  discard block
 block discarded – undo
218 216
     public function save (EntityInterface $entity): int {
219 217
         if (!$entity->getId()) {
220 218
             $this->saveInsert($entity);
221
-        }
222
-        else {
219
+        } else {
223 220
             $this->saveUpdate($entity);
224 221
         }
225 222
         $this->saveEav($entity);
Please login to merge, or discard this patch.
src/DB/AttributesTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     /**
23 23
      * @return array
24 24
      */
25
-    public function getAttributes (): array {
25
+    public function getAttributes(): array {
26 26
         return $this->attributes ?: [];
27 27
     }
28 28
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * @param $offset
31 31
      * @return bool
32 32
      */
33
-    public function offsetExists ($offset): bool {
33
+    public function offsetExists($offset): bool {
34 34
         return $this->attributes and array_key_exists($offset, $this->attributes);
35 35
     }
36 36
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param $offset
39 39
      * @return mixed Returns `NULL` for nonexistent attributes.
40 40
      */
41
-    public function offsetGet ($offset) {
41
+    public function offsetGet($offset) {
42 42
         return $this->attributes[$offset] ?? null;
43 43
     }
44 44
 
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
      * @param $offset
47 47
      * @param $value
48 48
      */
49
-    public function offsetSet ($offset, $value): void {
49
+    public function offsetSet($offset, $value): void {
50 50
         $this->attributes[$offset] = $value;
51 51
     }
52 52
 
53 53
     /**
54 54
      * @param $offset
55 55
      */
56
-    public function offsetUnset ($offset): void {
56
+    public function offsetUnset($offset): void {
57 57
         unset($this->attributes[$offset]);
58 58
     }
59 59
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param array $attributes
62 62
      * @return $this
63 63
      */
64
-    public function setAttributes (array $attributes) {
64
+    public function setAttributes(array $attributes) {
65 65
         $this->attributes = $attributes;
66 66
         return $this;
67 67
     }
Please login to merge, or discard this patch.
src/DB/SQL.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,11 +74,9 @@
 block discarded – undo
74 74
                 $cmp[$k] = static::compare($k, $operator, $v, $subqueryOperator, $listOperator);
75 75
             }
76 76
             return $cmp;
77
-        }
78
-        elseif (is_array($b)) {
77
+        } elseif (is_array($b)) {
79 78
             return "{$a} {$listOperator} (" . implode(',', $b) . ")";
80
-        }
81
-        elseif ($b instanceof Select) {
79
+        } elseif ($b instanceof Select) {
82 80
             return "{$a} {$operator} {$subqueryOperator} ({$b->toSql()})";
83 81
         }
84 82
         return "{$a} {$operator} {$b}";
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 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 string
19 19
      */
20
-    public static function all (array $conditions): string {
20
+    public static function all(array $conditions): string {
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 string
32 32
      */
33
-    public static function any (array $conditions): string {
33
+    public static function any(array $conditions): string {
34 34
         if (count($conditions) === 1) {
35 35
             return reset($conditions);
36 36
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param string $listOperator
70 70
      * @return string|array
71 71
      */
72
-    public static function compare ($a, $operator, $b = null, $subqueryOperator = null, $listOperator = null) {
72
+    public static function compare($a, $operator, $b = null, $subqueryOperator = null, $listOperator = null) {
73 73
         if (is_array($a)) {
74 74
             $cmp = [];
75 75
             foreach ($a as $k => $v) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * @param string|array|Select $b
94 94
      * @return string|array
95 95
      */
96
-    public static function isEqual ($a, $b = null) {
96
+    public static function isEqual($a, $b = null) {
97 97
         return static::compare($a, '=', $b, 'ANY', 'IN');
98 98
     }
99 99
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param string|Select $b
105 105
      * @return string|array
106 106
      */
107
-    public static function isGreater ($a, $b = null) {
107
+    public static function isGreater($a, $b = null) {
108 108
         return static::compare($a, '>', $b, 'ALL');
109 109
     }
110 110
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param string|Select $b
116 116
      * @return string|array
117 117
      */
118
-    public static function isGreaterOrEqual ($a, $b = null) {
118
+    public static function isGreaterOrEqual($a, $b = null) {
119 119
         return static::compare($a, '>=', $b, 'ALL');
120 120
     }
121 121
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param string|Select $b
127 127
      * @return string|array
128 128
      */
129
-    public static function isLess ($a, $b = null) {
129
+    public static function isLess($a, $b = null) {
130 130
         return static::compare($a, '<', $b, 'ALL');
131 131
     }
132 132
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      * @param string|Select $b
138 138
      * @return string|array
139 139
      */
140
-    public static function isLessOrEqual ($a, $b = null) {
140
+    public static function isLessOrEqual($a, $b = null) {
141 141
         return static::compare($a, '<=', $b, 'ALL');
142 142
     }
143 143
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      * @param string $pattern
149 149
      * @return string|array
150 150
      */
151
-    public static function isLike ($x, string $pattern = null) {
151
+    public static function isLike($x, string $pattern = null) {
152 152
         return static::compare($x, 'LIKE', $pattern);
153 153
     }
154 154
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @param null|bool $identity
160 160
      * @return string|array
161 161
      */
162
-    public static function isNot ($x, $identity) {
162
+    public static function isNot($x, $identity) {
163 163
         return static::compare($x, 'IS NOT', ['' => 'UNKNOWN', 1 => 'TRUE', 0 => 'FALSE'][$identity]);
164 164
     }
165 165
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @param string|array|Select $b
171 171
      * @return string|array
172 172
      */
173
-    public static function isNotEqual ($a, $b = null) {
173
+    public static function isNotEqual($a, $b = null) {
174 174
         return static::compare($a, '<>', $b, 'ALL', 'NOT IN');
175 175
     }
176 176
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param string $pattern
182 182
      * @return string|array
183 183
      */
184
-    public static function isNotLike ($x, string $pattern = null) {
184
+    public static function isNotLike($x, string $pattern = null) {
185 185
         return static::compare($x, 'NOT LIKE', $pattern);
186 186
     }
187 187
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @param string|array $x
192 192
      * @return string|array
193 193
      */
194
-    public static function isNotNull ($x) {
194
+    public static function isNotNull($x) {
195 195
         if (is_array($x)) {
196 196
             return array_map(__METHOD__, $x);
197 197
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param string $pattern
206 206
      * @return string|array
207 207
      */
208
-    public static function isNotRegExp ($x, string $pattern = null) {
208
+    public static function isNotRegExp($x, string $pattern = null) {
209 209
         return static::compare($x, 'NOT REGEXP', $pattern);
210 210
     }
211 211
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      * @param string $pattern
217 217
      * @return string|array
218 218
      */
219
-    public static function isRegExp ($x, string $pattern = null) {
219
+    public static function isRegExp($x, string $pattern = null) {
220 220
         return static::compare($x, 'REGEXP', $pattern);
221 221
     }
222 222
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * @param int|array|Countable $count
227 227
      * @return string[]
228 228
      */
229
-    public static function marks ($count): array {
229
+    public static function marks($count): array {
230 230
         if (is_array($count) or $count instanceof Countable) {
231 231
             $count = count($count);
232 232
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * @param string|array $x
240 240
      * @return string|array
241 241
      */
242
-    public static function not ($x) {
242
+    public static function not($x) {
243 243
         if (is_array($x)) {
244 244
             return array_map(__METHOD__, $x);
245 245
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      * @param string[] $columns
255 255
      * @return string[] `[column => :column]`
256 256
      */
257
-    public static function slots (array $columns): array {
257
+    public static function slots(array $columns): array {
258 258
         $slots = [];
259 259
         foreach ($columns as $column) {
260 260
             $slots[(string)$column] = ':' . str_replace('.', '__', $column);
@@ -262,6 +262,6 @@  discard block
 block discarded – undo
262 262
         return $slots;
263 263
     }
264 264
 
265
-    final private function __construct () { }
265
+    final private function __construct() { }
266 266
 
267 267
 }
268 268
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Junction.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@
 block discarded – undo
35 35
         $this->interface = $interface;
36 36
         try {
37 37
             $interface = new ReflectionClass($interface);
38
-        }
39
-        catch (ReflectionException $exception) {
38
+        } catch (ReflectionException $exception) {
40 39
             throw new LogicException('Unexpected ReflectionException', 0, $exception);
41 40
         }
42 41
         $doc = $interface->getDocComment();
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param DB $db
32 32
      * @param string $interface
33 33
      */
34
-    public function __construct (DB $db, string $interface) {
34
+    public function __construct(DB $db, string $interface) {
35 35
         $this->interface = $interface;
36 36
         try {
37 37
             $interface = new ReflectionClass($interface);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param EntityInterface $entity
58 58
      * @return int
59 59
      */
60
-    public function count (EntityInterface $entity): int {
60
+    public function count(EntityInterface $entity): int {
61 61
         $key = $this->getKey($entity);
62 62
         $count = $this->cache("count.{$key}", function() use ($key) {
63 63
             return $this->select(['COUNT(*)'])->where("{$key}=:id")->prepare();
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param string $class
76 76
      * @return Select
77 77
      */
78
-    public function getCollection (EntityInterface $owner, string $class): Select {
78
+    public function getCollection(EntityInterface $owner, string $class): Select {
79 79
         $record = $this->db->getRecord($class);
80 80
         $select = $record->select();
81 81
         $select->join($this, $this[$class]->isEqual($record['id']));
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     /**
87 87
      * @return string
88 88
      */
89
-    final public function getInterface (): string {
89
+    final public function getInterface(): string {
90 90
         return $this->interface;
91 91
     }
92 92
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @param EntityInterface|string $class
97 97
      * @return string
98 98
      */
99
-    public function getKey ($class): string {
99
+    public function getKey($class): string {
100 100
         if (is_object($class)) {
101 101
             $class = get_class($class);
102 102
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @param EntityInterface[] $entities
115 115
      * @return int Rows affected.
116 116
      */
117
-    public function link (array $entities): int {
117
+    public function link(array $entities): int {
118 118
         $apply = [];
119 119
         foreach ($entities as $entity) {
120 120
             $apply[$this->getKey($entity)] = $entity->getId();
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * @param string $name
129 129
      * @return bool
130 130
      */
131
-    public function offsetExists ($name): bool {
131
+    public function offsetExists($name): bool {
132 132
         return isset($this->columns[$name]) or isset($this->columns[$this->keys[$name]]);
133 133
     }
134 134
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @param string $name
139 139
      * @return Column
140 140
      */
141
-    public function offsetGet ($name): Column {
141
+    public function offsetGet($name): Column {
142 142
         return $this->columns[$name] ?? $this->columns[$this->keys[$name]];
143 143
     }
144 144
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @param EntityInterface[] $entities
152 152
      * @return int Rows affected.
153 153
      */
154
-    public function unlink (array $entities): int {
154
+    public function unlink(array $entities): int {
155 155
         $match = [];
156 156
         foreach ($entities as $entity) {
157 157
             $match[$this->getKey($entity)] = $entity->getId();
Please login to merge, or discard this patch.
src/DB/Statement.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * Required by PDO, and must be protected.
15 15
      */
16
-    protected function __construct () { }
16
+    protected function __construct() { }
17 17
 
18 18
     /**
19 19
      * PHP returns `false` instead of throwing if too many arguments were given.
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @return bool
24 24
      * @throws PDOException
25 25
      */
26
-    public function execute ($args = null) {
26
+    public function execute($args = null) {
27 27
         if ($result = !parent::execute($args)) {
28 28
             $info = $this->errorInfo();
29 29
             if ($info[0] == 0) {
Please login to merge, or discard this patch.
src/DB.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param string $passwd
48 48
      * @param array $options
49 49
      */
50
-    public function __construct ($dsn, $username = null, $passwd = null, $options = null) {
50
+    public function __construct($dsn, $username = null, $passwd = null, $options = null) {
51 51
         parent::__construct(...func_get_args());
52 52
         $this->setAttribute(self::ATTR_ERRMODE, self::ERRMODE_EXCEPTION);
53 53
         $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @param string $sql
64 64
      * @return int
65 65
      */
66
-    public function exec ($sql) {
66
+    public function exec($sql) {
67 67
         $this->logger->__invoke($sql);
68 68
         return parent::exec($sql);
69 69
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @return string
75 75
      */
76
-    final public function getDriver () {
76
+    final public function getDriver() {
77 77
         return $this->getAttribute(self::ATTR_DRIVER_NAME);
78 78
     }
79 79
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * @param string $interface
84 84
      * @return Junction
85 85
      */
86
-    public function getJunction ($interface) {
86
+    public function getJunction($interface) {
87 87
         if (!isset($this->junctions[$interface])) {
88 88
             $this->junctions[$interface] = new Junction($this, $interface);
89 89
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @param string|EntityInterface $class
97 97
      * @return Record
98 98
      */
99
-    public function getRecord ($class) {
99
+    public function getRecord($class) {
100 100
         if (is_object($class)) {
101 101
             $class = get_class($class);
102 102
         }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * @param string|array|Select|Closure $b
129 129
      * @return string|string[] Same type as `$a`, keys are not preserved.
130 130
      */
131
-    public function match ($a, $b = null) {
131
+    public function match($a, $b = null) {
132 132
         if (is_array($a)) {
133 133
             return array_map([$this, __FUNCTION__], array_keys($a), $a);
134 134
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @param string $access Class or interface name.
146 146
      * @return bool
147 147
      */
148
-    public function offsetExists ($access) {
148
+    public function offsetExists($access) {
149 149
         return (bool)$this->offsetGet($access);
150 150
     }
151 151
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * @param string $access Class or interface name.
154 154
      * @return Record|Junction|null
155 155
      */
156
-    public function offsetGet ($access) {
156
+    public function offsetGet($access) {
157 157
         if (class_exists($access)) {
158 158
             return $this->getRecord($access);
159 159
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @param void $value
171 171
      * @throws LogicException
172 172
      */
173
-    final public function offsetSet ($access, $value) {
173
+    final public function offsetSet($access, $value) {
174 174
         throw new LogicException('The schema cannot be altered by ArrayAccess.');
175 175
     }
176 176
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @param void $access
181 181
      * @throws LogicException
182 182
      */
183
-    final public function offsetUnset ($access) {
183
+    final public function offsetUnset($access) {
184 184
         $this->offsetSet($access, null);
185 185
     }
186 186
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @param array $options
192 192
      * @return PDOStatement
193 193
      */
194
-    public function prepare ($sql, $options = null) {
194
+    public function prepare($sql, $options = null) {
195 195
         $this->logger->__invoke($sql);
196 196
         return parent::prepare(...func_get_args());
197 197
     }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param array $ctorargs
206 206
      * @return PDOStatement
207 207
      */
208
-    public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
208
+    public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
209 209
         $this->logger->__invoke($sql);
210 210
         return parent::query(...func_get_args());
211 211
     }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      * @param int $type Ignored.
229 229
      * @return mixed
230 230
      */
231
-    public function quote ($value, $type = null) {
231
+    public function quote($value, $type = null) {
232 232
         if ($value instanceof Column) {
233 233
             return (string)$value;
234 234
         }
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
      * @param EntityInterface $entity
254 254
      * @return int ID
255 255
      */
256
-    public function save (EntityInterface $entity) {
256
+    public function save(EntityInterface $entity) {
257 257
         return $this->getRecord($entity)->save($entity);
258 258
     }
259 259
 
260 260
     /**
261 261
      * @param Closure $logger
262 262
      */
263
-    public function setLogger (Closure $logger) {
263
+    public function setLogger(Closure $logger) {
264 264
         $this->logger = $logger;
265 265
     }
266 266
 }
267 267
\ No newline at end of file
Please login to merge, or discard this patch.