Passed
Push — master ( e92e1f...a725e0 )
by y
06:32
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/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/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/Junction.php 1 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/AttributesTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * @return array
32 32
      */
33
-    public function getAttributes (): array {
33
+    public function getAttributes(): array {
34 34
         return $this->attributes ?? [];
35 35
     }
36 36
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param mixed $attr
39 39
      * @return bool
40 40
      */
41
-    public function offsetExists ($attr): bool {
41
+    public function offsetExists($attr): bool {
42 42
         return isset($this->attributes) and array_key_exists($attr, $this->attributes);
43 43
     }
44 44
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param mixed $attr
47 47
      * @return null|mixed
48 48
      */
49
-    public function offsetGet ($attr) {
49
+    public function offsetGet($attr) {
50 50
         return $this->attributes[$attr] ?? null;
51 51
     }
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param mixed $attr
55 55
      * @param mixed $value
56 56
      */
57
-    public function offsetSet ($attr, $value): void {
57
+    public function offsetSet($attr, $value): void {
58 58
         if (isset($attr)) {
59 59
             $this->attributes[$attr] = $value;
60 60
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     /**
67 67
      * @param mixed $attr
68 68
      */
69
-    public function offsetUnset ($attr): void {
69
+    public function offsetUnset($attr): void {
70 70
         unset($this->attributes[$attr]);
71 71
     }
72 72
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param array $attributes
75 75
      * @return $this
76 76
      */
77
-    public function setAttributes (array $attributes) {
77
+    public function setAttributes(array $attributes) {
78 78
         $this->attributes = $attributes;
79 79
         return $this;
80 80
     }
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
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @return string
18 18
      */
19
-    abstract public function __toString ();
19
+    abstract public function __toString();
20 20
 
21 21
     /**
22 22
      * @param int|string $column
23 23
      * @return null|Column
24 24
      */
25
-    abstract public function offsetGet ($column);
25
+    abstract public function offsetGet($column);
26 26
 
27 27
     /**
28 28
      * @var DB
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * @param DB $db
34 34
      */
35
-    public function __construct (DB $db) {
35
+    public function __construct(DB $db) {
36 36
         $this->db = $db;
37 37
     }
38 38
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param int|string $column
41 41
      * @return bool
42 42
      */
43
-    public function offsetExists ($column): bool {
43
+    public function offsetExists($column): bool {
44 44
         return $this->offsetGet($column) !== null;
45 45
     }
46 46
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param void $value
52 52
      * @throws Exception
53 53
      */
54
-    final public function offsetSet ($offset, $value): void {
54
+    final public function offsetSet($offset, $value): void {
55 55
         throw new Exception('Tables are immutable.');
56 56
     }
57 57
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param void $name
62 62
      * @throws Exception
63 63
      */
64
-    final public function offsetUnset ($name): void {
64
+    final public function offsetUnset($name): void {
65 65
         $this->offsetSet($name, null);
66 66
     }
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Record.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @param string|EntityInterface $class
65 65
      * @return Record
66 66
      */
67
-    public static function fromClass (DB $db, $class) {
67
+    public static function fromClass(DB $db, $class) {
68 68
         return (function() use ($db, $class) {
69 69
             $rClass = new ReflectionClass($class);
70 70
             $columns = [];
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * @param string[] $columns Property names.
94 94
      * @param EAV[] $eav Keyed by property name.
95 95
      */
96
-    public function __construct (DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) {
96
+    public function __construct(DB $db, EntityInterface $proto, string $table, array $columns, array $eav = []) {
97 97
         parent::__construct($db, $table, $columns);
98 98
         $this->proto = $proto;
99 99
         (function() use ($proto, $columns, $eav) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      * @param array[] $eavMatch `[eav property => attribute => mixed]`
131 131
      * @return Select
132 132
      */
133
-    public function find (array $match, array $eavMatch = []) {
133
+    public function find(array $match, array $eavMatch = []) {
134 134
         $select = $this->select();
135 135
         foreach ($match as $a => $b) {
136 136
             $select->where($this->db->match($this[$a] ?? $a, $b));
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      * @param Statement $statement
149 149
      * @return EntityInterface[] Keyed by ID
150 150
      */
151
-    public function getAll (Statement $statement): array {
151
+    public function getAll(Statement $statement): array {
152 152
         return iterator_to_array($this->getEach($statement));
153 153
     }
154 154
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @param Statement $statement
160 160
      * @return Generator|EntityInterface[] Keyed by ID
161 161
      */
162
-    public function getEach (Statement $statement) {
162
+    public function getEach(Statement $statement) {
163 163
         do {
164 164
             $entities = [];
165 165
             for ($i = 0; $i < 256 and false !== $row = $statement->fetch(); $i++) {
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
      * @param string $property
177 177
      * @return EAV
178 178
      */
179
-    final public function getEav (string $property) {
179
+    final public function getEav(string $property) {
180 180
         return $this->eav[$property];
181 181
     }
182 182
 
183 183
     /**
184 184
      * @return EntityInterface
185 185
      */
186
-    public function getProto () {
186
+    public function getProto() {
187 187
         return $this->proto;
188 188
     }
189 189
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @param EntityInterface $entity
192 192
      * @return array
193 193
      */
194
-    protected function getValues (EntityInterface $entity): array {
194
+    protected function getValues(EntityInterface $entity): array {
195 195
         $values = [];
196 196
         foreach (array_keys($this->columns) as $name) {
197 197
             $values[$name] = $this->properties[$name]->getValue($entity);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param int $id
206 206
      * @return null|EntityInterface
207 207
      */
208
-    public function load (int $id) {
208
+    public function load(int $id) {
209 209
         $load = $this->cache(__FUNCTION__, function() {
210 210
             return $this->select(array_keys($this->columns))->where('id = ?')->prepare();
211 211
         });
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      *
224 224
      * @param EntityInterface[] $entities
225 225
      */
226
-    protected function loadEav (array $entities): void {
226
+    protected function loadEav(array $entities): void {
227 227
         $ids = array_keys($entities);
228 228
         foreach ($this->eav as $name => $eav) {
229 229
             foreach ($eav->loadAll($ids) as $id => $values) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      * @param EntityInterface $entity
239 239
      * @return int ID
240 240
      */
241
-    public function save (EntityInterface $entity): int {
241
+    public function save(EntityInterface $entity): int {
242 242
         if (!$entity->getId()) {
243 243
             $this->saveInsert($entity);
244 244
         }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     /**
253 253
      * @param EntityInterface $entity
254 254
      */
255
-    protected function saveEav (EntityInterface $entity): void {
255
+    protected function saveEav(EntityInterface $entity): void {
256 256
         $id = $entity->getId();
257 257
         foreach ($this->eav as $name => $eav) {
258 258
             // may be null to skip
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      *
269 269
      * @param EntityInterface $entity
270 270
      */
271
-    protected function saveInsert (EntityInterface $entity): void {
271
+    protected function saveInsert(EntityInterface $entity): void {
272 272
         $insert = $this->cache(__FUNCTION__, function() {
273 273
             $slots = SQL::slots(array_keys($this->columns));
274 274
             unset($slots['id']);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      *
287 287
      * @param EntityInterface $entity
288 288
      */
289
-    protected function saveUpdate (EntityInterface $entity): void {
289
+    protected function saveUpdate(EntityInterface $entity): void {
290 290
         $this->cache(__FUNCTION__, function() {
291 291
             $slots = SQL::slotsEqual(array_keys($this->columns));
292 292
             unset($slots['id']);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      * @param array $columns Defaults to all columns.
302 302
      * @return Select
303 303
      */
304
-    public function select (array $columns = []) {
304
+    public function select(array $columns = []) {
305 305
         $select = parent::select($columns);
306 306
         if (empty($columns)) {
307 307
             $select->setFetcher(function(Statement $statement) {
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      * @param EntityInterface $proto
316 316
      * @return $this
317 317
      */
318
-    public function setProto (EntityInterface $proto) {
318
+    public function setProto(EntityInterface $proto) {
319 319
         $this->proto = $proto;
320 320
         return $this;
321 321
     }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      * @param EntityInterface $entity
325 325
      * @param array $values
326 326
      */
327
-    protected function setValues (EntityInterface $entity, array $values): void {
327
+    protected function setValues(EntityInterface $entity, array $values): void {
328 328
         foreach ($values as $name => $value) {
329 329
             settype($value, $this->types[$name]);
330 330
             $this->properties[$name]->setValue($entity, $value);
Please login to merge, or discard this patch.
src/DB/SQL.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
      * @param int|array|Countable $count
19 19
      * @return ExpressionInterface[]
20 20
      */
21
-    public static function marks ($count): array {
21
+    public static function marks($count): array {
22 22
         static $mark;
23 23
         $mark ??= new class implements ExpressionInterface {
24 24
 
25
-            public function __toString () {
25
+            public function __toString() {
26 26
                 return '?';
27 27
             }
28 28
         };
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param string[] $columns
42 42
      * @return string[] `["column" => ":column"]`
43 43
      */
44
-    public static function slots (array $columns): array {
44
+    public static function slots(array $columns): array {
45 45
         $slots = [];
46 46
         foreach ($columns as $column) {
47 47
             $slots[$column] = ':' . str_replace('.', '__', $column);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param string[] $columns
54 54
      * @return string[] `["column" => "column=:column"]`
55 55
      */
56
-    public static function slotsEqual (array $columns): array {
56
+    public static function slotsEqual(array $columns): array {
57 57
         $slots = static::slots($columns);
58 58
         foreach ($slots as $column => $slot) {
59 59
             $slots[$column] = "{$column} = {$slot}";
@@ -61,6 +61,6 @@  discard block
 block discarded – undo
61 61
         return $slots;
62 62
     }
63 63
 
64
-    final private function __construct () {
64
+    final private function __construct() {
65 65
     }
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.