Passed
Push — master ( 74bc2a...6c4562 )
by y
02:11
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 ();
13
+    public function getId();
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Statement.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @param DB $db
23 23
      */
24
-    protected function __construct (DB $db) {
24
+    protected function __construct(DB $db) {
25 25
         $this->db = $db;
26 26
     }
27 27
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param array $args
32 32
      * @return $this
33 33
      */
34
-    public function __invoke (array $args = null) {
34
+    public function __invoke(array $args = null) {
35 35
         $this->execute($args);
36 36
         return $this;
37 37
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return string
43 43
      */
44
-    public function __toString () {
44
+    public function __toString() {
45 45
         return $this->queryString;
46 46
     }
47 47
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return bool
55 55
      * @throws ArgumentCountError
56 56
      */
57
-    public function execute ($args = null) {
57
+    public function execute($args = null) {
58 58
         $this->db->getLogger()->__invoke($this->queryString);
59 59
         if ($result = !parent::execute($args)) {
60 60
             $info = $this->errorInfo();
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return int
73 73
      */
74
-    public function getId (): int {
74
+    public function getId(): int {
75 75
         return (int)$this->db->lastInsertId();
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
src/DB/SQL.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * @param int|array|Countable $count
20 20
      * @return ExpressionInterface[]
21 21
      */
22
-    public static function marks ($count): array {
22
+    public static function marks($count): array {
23 23
         if (is_array($count) or $count instanceof Countable) {
24 24
             $count = count($count);
25 25
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param string[] $columns
35 35
      * @return string[] `["column" => ":column"]`
36 36
      */
37
-    public static function slots (array $columns): array {
37
+    public static function slots(array $columns): array {
38 38
         $slots = [];
39 39
         foreach ($columns as $column) {
40 40
             $slots[(string)$column] = ':' . str_replace('.', '__', $column);
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param string[] $columns
47 47
      * @return string[] `["column" => "column=:column"]`
48 48
      */
49
-    public static function slotsEqual (array $columns): array {
49
+    public static function slotsEqual(array $columns): array {
50 50
         $slots = static::slots($columns);
51 51
         foreach ($slots as $column => $slot) {
52 52
             $slots[$column] = "{$column} = {$slot}";
@@ -54,5 +54,5 @@  discard block
 block discarded – undo
54 54
         return $slots;
55 55
     }
56 56
 
57
-    final private function __construct () { }
57
+    final private function __construct() { }
58 58
 }
59 59
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Column.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param string $name
39 39
      * @param string $qualifier
40 40
      */
41
-    public function __construct (DB $db, string $name, string $qualifier = '') {
41
+    public function __construct(DB $db, string $name, string $qualifier = '') {
42 42
         $this->db = $db;
43 43
         $this->name = $name;
44 44
         $this->qualifier = $qualifier;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      *
50 50
      * @return string
51 51
      */
52
-    public function __toString (): string {
52
+    public function __toString(): string {
53 53
         if (strlen($this->qualifier)) {
54 54
             return "{$this->qualifier}.{$this->name}";
55 55
         }
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @return string
61 61
      */
62
-    final public function getName (): string {
62
+    final public function getName(): string {
63 63
         return $this->name;
64 64
     }
65 65
 
66 66
     /**
67 67
      * @return string
68 68
      */
69
-    final public function getQualifier (): string {
69
+    final public function getQualifier(): string {
70 70
         return $this->qualifier;
71 71
     }
72 72
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string $name
75 75
      * @return $this
76 76
      */
77
-    public function setName (string $name) {
77
+    public function setName(string $name) {
78 78
         $clone = clone $this;
79 79
         $clone->name = $name;
80 80
         return $clone;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param string $qualifier
85 85
      * @return $this
86 86
      */
87
-    public function setQualifier (string $qualifier) {
87
+    public function setQualifier(string $qualifier) {
88 88
         $clone = clone $this;
89 89
         $clone->qualifier = $qualifier;
90 90
         return $clone;
Please login to merge, or discard this patch.
src/DB/SQL/Expression.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
     /**
16 16
      * @param string $expression
17 17
      */
18
-    public function __construct (string $expression) {
18
+    public function __construct(string $expression) {
19 19
         $this->expression = $expression;
20 20
     }
21 21
 
22 22
     /**
23 23
      * @return string
24 24
      */
25
-    public function __toString () {
25
+    public function __toString() {
26 26
         return $this->expression;
27 27
     }
28 28
 }
29 29
\ 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
@@ -31,8 +31,7 @@
 block discarded – undo
31 31
     public static function fromInterface (DB $db, string $interface) {
32 32
         try {
33 33
             $ref = new ReflectionClass($interface);
34
-        }
35
-        catch (ReflectionException $exception) {
34
+        } catch (ReflectionException $exception) {
36 35
             throw new LogicException('Unexpected ReflectionException', 0, $exception);
37 36
         }
38 37
         $doc = $ref->getDocComment();
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param string $interface
30 30
      * @return Junction
31 31
      */
32
-    public static function fromInterface (DB $db, string $interface) {
32
+    public static function fromInterface(DB $db, string $interface) {
33 33
         try {
34 34
             $ref = new ReflectionClass($interface);
35 35
         }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param string $table
53 53
      * @param string[] $classes
54 54
      */
55
-    public function __construct (DB $db, string $table, array $classes) {
55
+    public function __construct(DB $db, string $table, array $classes) {
56 56
         parent::__construct($db, $table, array_keys($classes));
57 57
         $this->classes = $classes;
58 58
     }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param array $match Keyed by junction column.
67 67
      * @return Select
68 68
      */
69
-    public function getCollection (string $key, array $match = []) {
69
+    public function getCollection(string $key, array $match = []) {
70 70
         $record = $this->db->getRecord($this->classes[$key]);
71 71
         $select = $record->select();
72 72
         $select->join($this, $this[$key]->isEqual($record['id']));
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @param int[] $ids Keyed by column.
83 83
      * @return int Rows affected.
84 84
      */
85
-    public function link (array $ids): int {
85
+    public function link(array $ids): int {
86 86
         $link = $this->cache(__FUNCTION__, function() {
87 87
             $columns = implode(',', array_keys($this->columns));
88 88
             $slots = implode(',', SQL::slots(array_keys($this->columns)));
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @param array $ids Keyed by Column
107 107
      * @return int Rows affected
108 108
      */
109
-    public function unlink (array $ids): int {
109
+    public function unlink(array $ids): int {
110 110
         return $this->delete($ids);
111 111
     }
112 112
 }
113 113
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/EAV.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      * @param DB $db
15 15
      * @param $name
16 16
      */
17
-    public function __construct (DB $db, $name) {
17
+    public function __construct(DB $db, $name) {
18 18
         parent::__construct($db, $name, ['entity', 'attribute', 'value']);
19 19
     }
20 20
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @param string $attribute
26 26
      * @return bool
27 27
      */
28
-    public function exists (int $id, string $attribute): bool {
28
+    public function exists(int $id, string $attribute): bool {
29 29
         $exists = $this->cache(__FUNCTION__, function() {
30 30
             $select = $this->select(['COUNT(*) > 0']);
31 31
             $select->where('entity = ? AND attribute = ?');
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute.
44 44
      * @return Select
45 45
      */
46
-    public function find (array $match) {
46
+    public function find(array $match) {
47 47
         $select = $this->select([$this['entity']]);
48 48
         $prior = $this;
49 49
         foreach ($match as $attribute => $value) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param int $id
66 66
      * @return array `[attribute => value]`
67 67
      */
68
-    public function load (int $id): array {
68
+    public function load(int $id): array {
69 69
         $load = $this->cache(__FUNCTION__, function() {
70 70
             $select = $this->select(['attribute', 'value']);
71 71
             $select->where('entity = ?');
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param int[] $ids
82 82
      * @return array[] `[id => attribute => value]
83 83
      */
84
-    public function loadAll (array $ids): array {
84
+    public function loadAll(array $ids): array {
85 85
         if (empty($ids)) {
86 86
             return [];
87 87
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @param array $values `[attribute => value]`
107 107
      * @return $this
108 108
      */
109
-    public function save (int $id, array $values) {
109
+    public function save(int $id, array $values) {
110 110
         $this->delete([
111 111
             $this['entity']->isEqual($id),
112 112
             $this['attribute']->isNotEqual(array_keys($values))
Please login to merge, or discard this patch.
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   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param string $password
53 53
      * @param array $options
54 54
      */
55
-    public function __construct ($dsn, $username = null, $password = null, $options = null) {
55
+    public function __construct($dsn, $username = null, $password = null, $options = null) {
56 56
         parent::__construct($dsn, $username, $password, $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
      *
75 75
      * @return string
76 76
      */
77
-    final public function __toString () {
77
+    final public function __toString() {
78 78
         return $this->driver;
79 79
     }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param string $sql
85 85
      * @return int
86 86
      */
87
-    public function exec ($sql): int {
87
+    public function exec($sql): int {
88 88
         $this->logger->__invoke($sql);
89 89
         return parent::exec($sql);
90 90
     }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
      * @param mixed ...$args
99 99
      * @return mixed
100 100
      */
101
-    public function factory (string $class, ...$args) {
101
+    public function factory(string $class, ...$args) {
102 102
         return new $class(...$args);
103 103
     }
104 104
 
105 105
     /**
106 106
      * @return string
107 107
      */
108
-    final public function getDriver (): string {
108
+    final public function getDriver(): string {
109 109
         return $this->driver;
110 110
     }
111 111
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param string $interface
116 116
      * @return Junction
117 117
      */
118
-    public function getJunction ($interface) {
118
+    public function getJunction($interface) {
119 119
         if (!isset($this->junctions[$interface])) {
120 120
             $this->junctions[$interface] = Junction::fromInterface($this, $interface);
121 121
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * @return Closure
127 127
      */
128
-    public function getLogger () {
128
+    public function getLogger() {
129 129
         return $this->logger;
130 130
     }
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @param string|EntityInterface $class
136 136
      * @return Record
137 137
      */
138
-    public function getRecord ($class) {
138
+    public function getRecord($class) {
139 139
         if (is_object($class)) {
140 140
             $class = get_class($class);
141 141
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @param mixed $b
163 163
      * @return Predicate
164 164
      */
165
-    public function match ($a, $b) {
165
+    public function match($a, $b) {
166 166
         if ($b instanceof Closure) {
167 167
             return $b->__invoke($a, $this);
168 168
         }
@@ -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 Optional.
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());
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      * @param int $type Ignored.
263 263
      * @return string|ExpressionInterface
264 264
      */
265
-    public function quote ($value, $type = self::PARAM_STR) {
265
+    public function quote($value, $type = self::PARAM_STR) {
266 266
         if ($value instanceof ExpressionInterface) {
267 267
             return $value;
268 268
         }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @param array $values
283 283
      * @return string[]
284 284
      */
285
-    public function quoteArray (array $values) {
285
+    public function quoteArray(array $values) {
286 286
         return array_map([$this, 'quote'], $values);
287 287
     }
288 288
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
      * @param array $values
293 293
      * @return string
294 294
      */
295
-    public function quoteList (array $values): string {
295
+    public function quoteList(array $values): string {
296 296
         return implode(',', $this->quoteArray($values));
297 297
     }
298 298
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      * @param EntityInterface $entity
303 303
      * @return int ID
304 304
      */
305
-    public function save (EntityInterface $entity): int {
305
+    public function save(EntityInterface $entity): int {
306 306
         return $this->getRecord($entity)->save($entity);
307 307
     }
308 308
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      * @param Junction $junction
312 312
      * @return $this
313 313
      */
314
-    public function setJunction (string $interface, Junction $junction) {
314
+    public function setJunction(string $interface, Junction $junction) {
315 315
         $this->junctions[$interface] = $junction;
316 316
         return $this;
317 317
     }
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      * @param Closure $logger
321 321
      * @return $this
322 322
      */
323
-    public function setLogger (Closure $logger) {
323
+    public function setLogger(Closure $logger) {
324 324
         $this->logger = $logger;
325 325
         return $this;
326 326
     }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      * @param Record $record
331 331
      * @return $this
332 332
      */
333
-    public function setRecord (string $class, Record $record) {
333
+    public function setRecord(string $class, Record $record) {
334 334
         $this->records[$class] = $record;
335 335
         return $this;
336 336
     }
Please login to merge, or discard this patch.