Passed
Push — master ( 9b561d...08d227 )
by y
01:25
created
src/DB.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param string $passwd
54 54
      * @param array $options
55 55
      */
56
-    public function __construct ($dsn, $username = null, $passwd = null, $options = null) {
56
+    public function __construct($dsn, $username = null, $passwd = null, $options = null) {
57 57
         parent::__construct($dsn, $username, $passwd, $options);
58 58
         $this->driver = $this->getAttribute(self::ATTR_DRIVER_NAME);
59 59
         $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): Junction {
95
+    public function getJunction($interface): Junction {
96 96
         if (!isset($this->junctions[$interface])) {
97 97
             $this->junctions[$interface] = new Junction($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 (): Closure {
105
+    public function getLogger(): Closure {
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): Record {
115
+    public function getRecord($class): Record {
116 116
         if (is_object($class)) {
117 117
             $class = get_class($class);
118 118
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @param mixed $b
137 137
      * @return string
138 138
      */
139
-    public function match ($a, $b) {
139
+    public function match($a, $b) {
140 140
         if ($b instanceof Closure) {
141 141
             if (!$a instanceof Column) {
142 142
                 $a = new Column($this, $a);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @param array $match
163 163
      * @return string[]
164 164
      */
165
-    public function matchArray (array $match) {
165
+    public function matchArray(array $match) {
166 166
         return array_map([$this, 'match'], array_keys($match), $match);
167 167
     }
168 168
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @param string $access Class or interface name.
171 171
      * @return bool
172 172
      */
173
-    public function offsetExists ($access): bool {
173
+    public function offsetExists($access): bool {
174 174
         return (bool)$this->offsetGet($access);
175 175
     }
176 176
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @param string $access Class or interface name.
179 179
      * @return null|Record|Junction
180 180
      */
181
-    public function offsetGet ($access) {
181
+    public function offsetGet($access) {
182 182
         if (class_exists($access)) {
183 183
             return $this->getRecord($access);
184 184
         }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @param void $value
196 196
      * @throws Exception
197 197
      */
198
-    final public function offsetSet ($access, $value): void {
198
+    final public function offsetSet($access, $value): void {
199 199
         throw new Exception('The schema is immutable.');
200 200
     }
201 201
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param void $access
206 206
      * @throws Exception
207 207
      */
208
-    final public function offsetUnset ($access): void {
208
+    final public function offsetUnset($access): void {
209 209
         $this->offsetSet($access, null);
210 210
     }
211 211
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      * @param array $options
217 217
      * @return Statement
218 218
      */
219
-    public function prepare ($sql, $options = []): Statement {
219
+    public function prepare($sql, $options = []): Statement {
220 220
         $this->logger->__invoke($sql);
221 221
         /** @var Statement $statement */
222 222
         $statement = parent::prepare($sql, $options);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @param array $ctorargs
233 233
      * @return Statement
234 234
      */
235
-    public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []): Statement {
235
+    public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []): Statement {
236 236
         $this->logger->__invoke($sql);
237 237
         /** @var Statement $statement */
238 238
         $statement = parent::query(...func_get_args());
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @param int $type Ignored.
252 252
      * @return string
253 253
      */
254
-    public function quote ($value, $type = null) {
254
+    public function quote($value, $type = null) {
255 255
         if ($value instanceof ExpressionInterface) {
256 256
             return $value;
257 257
         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      * @param array $values
272 272
      * @return array
273 273
      */
274
-    public function quoteArray (array $values): array {
274
+    public function quoteArray(array $values): array {
275 275
         return array_map([$this, 'quote'], $values);
276 276
     }
277 277
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      * @param mixed $value
282 282
      * @return array|string
283 283
      */
284
-    public function quoteMixed ($value) {
284
+    public function quoteMixed($value) {
285 285
         if (is_array($value)) {
286 286
             return $this->quoteArray($value);
287 287
         }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      * @param EntityInterface $entity
295 295
      * @return int ID
296 296
      */
297
-    public function save (EntityInterface $entity): int {
297
+    public function save(EntityInterface $entity): int {
298 298
         return $this->getRecord($entity)->save($entity);
299 299
     }
300 300
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      * @param Closure $logger
303 303
      * @return $this
304 304
      */
305
-    public function setLogger (Closure $logger) {
305
+    public function setLogger(Closure $logger) {
306 306
         $this->logger = $logger;
307 307
         return $this;
308 308
     }
Please login to merge, or discard this patch.
src/DB/Table.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param string $name
32 32
      * @param string[] $columns
33 33
      */
34
-    public function __construct (DB $db, $name, array $columns) {
34
+    public function __construct(DB $db, $name, array $columns) {
35 35
         parent::__construct($db);
36 36
         $this->name = $name;
37 37
         foreach ($columns as $column) {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      *
45 45
      * @return string
46 46
      */
47
-    final public function __toString () {
47
+    final public function __toString() {
48 48
         return $this->name;
49 49
     }
50 50
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @param array $match
57 57
      * @return int Rows affected.
58 58
      */
59
-    public function delete (array $match): int {
59
+    public function delete(array $match): int {
60 60
         $match = Predicate::all($this->db->matchArray($match));
61 61
         return $this->db->exec("DELETE FROM {$this} WHERE {$match}");
62 62
     }
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * @return Column[]
66 66
      */
67
-    final public function getColumns (): array {
67
+    final public function getColumns(): array {
68 68
         return $this->columns;
69 69
     }
70 70
 
71 71
     /**
72 72
      * @return string
73 73
      */
74
-    final public function getName (): string {
74
+    final public function getName(): string {
75 75
         return $this->name;
76 76
     }
77 77
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param array $values
82 82
      * @return Statement
83 83
      */
84
-    public function insert (array $values): Statement {
84
+    public function insert(array $values): Statement {
85 85
         $columns = implode(',', array_keys($values));
86 86
         $values = implode(', ', $this->db->quoteArray($values));
87 87
         return $this->db->query("INSERT INTO {$this} ($columns) VALUES ($values)");
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param string $name
92 92
      * @return bool
93 93
      */
94
-    public function offsetExists ($name): bool {
94
+    public function offsetExists($name): bool {
95 95
         return isset($this->columns[$name]);
96 96
     }
97 97
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      * @param string $name
100 100
      * @return Column
101 101
      */
102
-    public function offsetGet ($name): Column {
102
+    public function offsetGet($name): Column {
103 103
         return $this->columns[$name];
104 104
     }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @param string[] $columns Defaults to all columns.
110 110
      * @return Select
111 111
      */
112
-    public function select (array $columns = []): Select {
112
+    public function select(array $columns = []): Select {
113 113
         if (!$columns) {
114 114
             $columns = array_values($this->columns);
115 115
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param string $name
123 123
      * @return Table
124 124
      */
125
-    public function setName (string $name) {
125
+    public function setName(string $name) {
126 126
         $clone = clone $this;
127 127
         $clone->name = $name;
128 128
         foreach ($this->columns as $name => $column) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      * @param array $match
141 141
      * @return int Rows affected.
142 142
      */
143
-    public function update (array $values, array $match): int {
143
+    public function update(array $values, array $match): int {
144 144
         $values = implode(', ', $this->db->matchArray($values));
145 145
         $match = Predicate::all($this->db->matchArray($match));
146 146
         return $this->db->exec("UPDATE {$this} SET {$values} WHERE {$match}");
Please login to merge, or discard this patch.
src/DB/Select.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param string|Select $table
82 82
      * @param string[] $columns
83 83
      */
84
-    public function __construct (DB $db, $table, array $columns) {
84
+    public function __construct(DB $db, $table, array $columns) {
85 85
         parent::__construct($db);
86 86
         if ($table instanceof Select) {
87 87
             $table = $table->toSubquery();
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     /**
98 98
      * Gives the clone a new alias.
99 99
      */
100
-    public function __clone () {
100
+    public function __clone() {
101 101
         $this->alias = uniqid('_') . "__{$this->table}";
102 102
     }
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @param array $args
106 106
      * @return Statement
107 107
      */
108
-    public function __invoke (array $args = []): Statement {
108
+    public function __invoke(array $args = []): Statement {
109 109
         return $this->execute($args);
110 110
     }
111 111
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      *
115 115
      * @return string
116 116
      */
117
-    final public function __toString () {
117
+    final public function __toString() {
118 118
         return $this->alias;
119 119
     }
120 120
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @param array $args Execution arguments.
125 125
      * @return int
126 126
      */
127
-    public function count (array $args = []): int {
127
+    public function count(array $args = []): int {
128 128
         $clone = clone $this;
129 129
         $clone->columns = ['COUNT(*)'];
130 130
         return (int)$clone->execute($args)->fetchColumn();
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @param array $args
137 137
      * @return Statement
138 138
      */
139
-    public function execute (array $args = []): Statement {
139
+    public function execute(array $args = []): Statement {
140 140
         if (!empty($args)) {
141 141
             return $this->prepare()($args);
142 142
         }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @param array $args Execution arguments.
152 152
      * @return array
153 153
      */
154
-    public function fetchAll (array $args = []): array {
154
+    public function fetchAll(array $args = []): array {
155 155
         return $this->fetcher->__invoke($this->execute($args));
156 156
     }
157 157
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      *
163 163
      * @return ArrayIterator
164 164
      */
165
-    public function getIterator () {
165
+    public function getIterator() {
166 166
         return new ArrayIterator($this->fetchAll());
167 167
     }
168 168
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * @param string $column
173 173
      * @return $this
174 174
      */
175
-    public function group (string $column) {
175
+    public function group(string $column) {
176 176
         $this->_group[] = $column;
177 177
         return $this;
178 178
     }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      * @param string $condition
184 184
      * @return $this
185 185
      */
186
-    public function having (string $condition) {
186
+    public function having(string $condition) {
187 187
         $this->_having[] = $condition;
188 188
         return $this;
189 189
     }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @param string $type
197 197
      * @return $this
198 198
      */
199
-    public function join ($table, string $condition, string $type = 'INNER') {
199
+    public function join($table, string $condition, string $type = 'INNER') {
200 200
         if ($table instanceof Select) {
201 201
             $table = $table->toSubquery();
202 202
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      * @param int $offset
212 212
      * @return $this
213 213
      */
214
-    public function limit (int $limit, int $offset = 0) {
214
+    public function limit(int $limit, int $offset = 0) {
215 215
         $this->_limit = $limit;
216 216
         $this->_offset = $offset;
217 217
         return $this;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * @param string $name Name or alias if used.
224 224
      * @return bool
225 225
      */
226
-    public function offsetExists ($name): bool {
226
+    public function offsetExists($name): bool {
227 227
         return true;
228 228
     }
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @param string $name Name, or alias if used.
234 234
      * @return Column
235 235
      */
236
-    public function offsetGet ($name): Column {
236
+    public function offsetGet($name): Column {
237 237
         return new Column($this->db, $name, $this->alias);
238 238
     }
239 239
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      * @param string $order
244 244
      * @return $this
245 245
      */
246
-    public function order (string $order) {
246
+    public function order(string $order) {
247 247
         $this->_order = $order;
248 248
         return $this;
249 249
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     /**
252 252
      * @return Statement
253 253
      */
254
-    public function prepare (): Statement {
254
+    public function prepare(): Statement {
255 255
         return $this->db->prepare($this->toSql());
256 256
     }
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      * @param Closure $fetcher
260 260
      * @return $this
261 261
      */
262
-    public function setFetcher (Closure $fetcher) {
262
+    public function setFetcher(Closure $fetcher) {
263 263
         $this->fetcher = $fetcher;
264 264
         return $this;
265 265
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     /**
268 268
      * @return string
269 269
      */
270
-    public function toSql (): string {
270
+    public function toSql(): string {
271 271
         $columns = [];
272 272
         foreach ($this->columns as $alias => $name) {
273 273
             if (is_string($alias) and $name !== $alias) {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      *
308 308
      * @return string
309 309
      */
310
-    public function toSubquery (): string {
310
+    public function toSubquery(): string {
311 311
         return "({$this->toSql()}) AS {$this->alias}";
312 312
     }
313 313
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
      * @param string $condition
318 318
      * @return $this
319 319
      */
320
-    public function where (string $condition) {
320
+    public function where(string $condition) {
321 321
         $this->_where[] = $condition;
322 322
         return $this;
323 323
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -272,8 +272,7 @@
 block discarded – undo
272 272
         foreach ($this->columns as $alias => $name) {
273 273
             if (is_string($alias) and $name !== $alias) {
274 274
                 $columns[] = "{$name} AS {$alias}";
275
-            }
276
-            else {
275
+            } else {
277 276
                 $columns[] = $name;
278 277
             }
279 278
         }
Please login to merge, or discard this patch.
src/DB/EAV.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * @param Record $record The entity's storage access.
20 20
      * @param $name
21 21
      */
22
-    public function __construct (Record $record, $name) {
22
+    public function __construct(Record $record, $name) {
23 23
         $this->record = $record;
24 24
         parent::__construct($record->db, $name, ['entity', 'attribute', 'value']);
25 25
     }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * @param int $id
31 31
      * @return int
32 32
      */
33
-    public function count (int $id): int {
33
+    public function count(int $id): int {
34 34
         $count = $this->cache(__FUNCTION__, function() {
35 35
             return $this->select(['COUNT(*)'])->where('entity=?')->prepare();
36 36
         });
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param string $attribute
45 45
      * @return bool
46 46
      */
47
-    public function exists (int $id, string $attribute): bool {
47
+    public function exists(int $id, string $attribute): bool {
48 48
         $exists = $this->cache(__FUNCTION__, function() {
49 49
             $select = $this->select(['COUNT(*) > 0']);
50 50
             $select->where('entity = ? AND attribute = ?');
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param array $match `[attribute => value]`. If empty, selects all IDs for entities having at least one attribute.
63 63
      * @return Select
64 64
      */
65
-    public function find (array $match): Select {
65
+    public function find(array $match): Select {
66 66
         $select = $this->select([$this['entity']]);
67 67
         $prior = $this;
68 68
         foreach ($match as $attribute => $value) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param int $id
85 85
      * @return array `[attribute => value]`
86 86
      */
87
-    public function load (int $id): array {
87
+    public function load(int $id): array {
88 88
         $load = $this->cache(__FUNCTION__, function() {
89 89
             $select = $this->select(['attribute', 'value']);
90 90
             $select->where('entity = ?');
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @param int[] $ids
101 101
      * @return array[] `[id => attribute => value]
102 102
      */
103
-    public function loadAll (array $ids): array {
103
+    public function loadAll(array $ids): array {
104 104
         if (count($ids) === 1) {
105 105
             return [current($ids) => $this->load(current($ids))];
106 106
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param array $values `[attribute => value]`
123 123
      * @return $this
124 124
      */
125
-    public function save (int $id, array $values) {
125
+    public function save(int $id, array $values) {
126 126
         $this->delete([
127 127
             $this['entity']->isEqual($id),
128 128
             $this['attribute']->isNotEqual(array_keys($values))
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/Junction.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param DB $db
33 33
      * @param string $interface
34 34
      */
35
-    public function __construct (DB $db, string $interface) {
35
+    public function __construct(DB $db, string $interface) {
36 36
         $this->interface = $interface;
37 37
         try {
38 38
             $interface = new ReflectionClass($interface);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @param EntityInterface $entity
59 59
      * @return int
60 60
      */
61
-    public function count (EntityInterface $entity): int {
61
+    public function count(EntityInterface $entity): int {
62 62
         $key = $this->getKey($entity);
63 63
         $count = $this->cache("count.{$key}", function() use ($key) {
64 64
             return $this->select(['COUNT(*)'])->where("{$key} = ?")->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
         $link = $this->cache(__FUNCTION__, function() {
119 119
             $slots = implode(',', SQL::slots($this->keys));
120 120
             $columns = implode(',', $this->keys);
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @param string $name
137 137
      * @return bool
138 138
      */
139
-    public function offsetExists ($name): bool {
139
+    public function offsetExists($name): bool {
140 140
         return isset($this->columns[$name]) or isset($this->keys[$name]);
141 141
     }
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * @param string $name
147 147
      * @return Column
148 148
      */
149
-    public function offsetGet ($name): Column {
149
+    public function offsetGet($name): Column {
150 150
         return $this->columns[$name] ?? $this->columns[$this->keys[$name]];
151 151
     }
152 152
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @param EntityInterface[] $entities
160 160
      * @return int Rows affected.
161 161
      */
162
-    public function unlink (array $entities): int {
162
+    public function unlink(array $entities): int {
163 163
         $unlink = $this->cache(__FUNCTION__, function() {
164 164
             $slots = Predicate::all(SQL::slotsEqual($this->keys));
165 165
             return $this->db->prepare("DELETE FROM {$this} WHERE {$slots}");
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/AbstractTable.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @param DB $db
29 29
      */
30
-    public function __construct (DB $db) {
30
+    public function __construct(DB $db) {
31 31
         $this->db = $db;
32 32
     }
33 33
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return string
38 38
      */
39
-    abstract public function __toString ();
39
+    abstract public function __toString();
40 40
 
41 41
     /**
42 42
      * Caches a prepared query.
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param Closure $prepare `():Statement`
46 46
      * @return Statement
47 47
      */
48
-    protected function cache (string $key, Closure $prepare): Statement {
48
+    protected function cache(string $key, Closure $prepare): Statement {
49 49
         return $this->_cache[$key] ?? $this->_cache[$key] = $prepare->__invoke();
50 50
     }
51 51
 
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
      * @param string $name
54 54
      * @return bool
55 55
      */
56
-    abstract public function offsetExists ($name): bool;
56
+    abstract public function offsetExists($name): bool;
57 57
 
58 58
     /**
59 59
      * @param string $name
60 60
      * @return Column
61 61
      */
62
-    abstract public function offsetGet ($name): Column;
62
+    abstract public function offsetGet($name): Column;
63 63
 
64 64
     /**
65 65
      * Throws.
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param void $value
69 69
      * @throws Exception
70 70
      */
71
-    final public function offsetSet ($name, $value): void {
71
+    final public function offsetSet($name, $value): void {
72 72
         throw new Exception('Tables are immutable.');
73 73
     }
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param void $name
79 79
      * @throws Exception
80 80
      */
81
-    final public function offsetUnset ($name): void {
81
+    final public function offsetUnset($name): void {
82 82
         $this->offsetSet($name, null);
83 83
     }
84 84
 }
85 85
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Record.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param DB $db
63 63
      * @param string $class
64 64
      */
65
-    public function __construct (DB $db, string $class) {
65
+    public function __construct(DB $db, string $class) {
66 66
         $this->class = $class;
67 67
         try {
68 68
             $class = new ReflectionClass($class);
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @param Statement $statement
106 106
      * @return EntityInterface[] Enumerated
107 107
      */
108
-    public function fetchAll (Statement $statement): array {
108
+    public function fetchAll(Statement $statement): array {
109 109
         $entities = [];
110 110
         foreach ($statement->fetchAll() as $row) {
111 111
             $clone = clone $this->proto;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @param array[] $eavMatch Additional `[eav property => attribute => mixed]`
126 126
      * @return Select
127 127
      */
128
-    public function find (array $match, array $eavMatch = []): Select {
128
+    public function find(array $match, array $eavMatch = []): Select {
129 129
         $select = $this->select();
130 130
         foreach ($match as $column => $value) {
131 131
             $select->where($this->db->match($column, $value));
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     /**
141 141
      * @return string
142 142
      */
143
-    final public function getClass (): string {
143
+    final public function getClass(): string {
144 144
         return $this->class;
145 145
     }
146 146
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
      * @param string $property
149 149
      * @return EAV
150 150
      */
151
-    final public function getEav (string $property): EAV {
151
+    final public function getEav(string $property): EAV {
152 152
         return $this->eav[$property];
153 153
     }
154 154
 
155 155
     /**
156 156
      * @return EntityInterface
157 157
      */
158
-    public function getProto (): EntityInterface {
158
+    public function getProto(): EntityInterface {
159 159
         return $this->proto;
160 160
     }
161 161
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param EntityInterface $entity
164 164
      * @return array
165 165
      */
166
-    protected function getValues (EntityInterface $entity): array {
166
+    protected function getValues(EntityInterface $entity): array {
167 167
         $values = [];
168 168
         foreach (array_keys($this->columns) as $name) {
169 169
             $values[$name] = $this->properties[$name]->getValue($entity);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      * @param int $id
178 178
      * @return null|EntityInterface
179 179
      */
180
-    public function load (int $id): ?EntityInterface {
180
+    public function load(int $id): ?EntityInterface {
181 181
         $load = $this->cache(__FUNCTION__, function() {
182 182
             return $this->select(array_keys($this->columns))->where('id = ?')->prepare();
183 183
         });
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      *
196 196
      * @param EntityInterface[] $entities
197 197
      */
198
-    protected function loadEav (array $entities): void {
198
+    protected function loadEav(array $entities): void {
199 199
         $ids = array_keys($entities);
200 200
         foreach ($this->eav as $name => $eav) {
201 201
             foreach ($eav->loadAll($ids) as $id => $values) {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      * @param EntityInterface $entity
211 211
      * @return int ID
212 212
      */
213
-    public function save (EntityInterface $entity): int {
213
+    public function save(EntityInterface $entity): int {
214 214
         if (!$entity->getId()) {
215 215
             $this->saveInsert($entity);
216 216
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     /**
225 225
      * @param EntityInterface $entity
226 226
      */
227
-    protected function saveEav (EntityInterface $entity): void {
227
+    protected function saveEav(EntityInterface $entity): void {
228 228
         $id = $entity->getId();
229 229
         foreach ($this->eav as $name => $eav) {
230 230
             $values = $this->properties[$name]->getValue($entity);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      *
240 240
      * @param EntityInterface $entity
241 241
      */
242
-    protected function saveInsert (EntityInterface $entity): void {
242
+    protected function saveInsert(EntityInterface $entity): void {
243 243
         $insert = $this->cache(__FUNCTION__, function() {
244 244
             $slots = SQL::slots(array_keys($this->columns));
245 245
             unset($slots['id']);
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      *
258 258
      * @param EntityInterface $entity
259 259
      */
260
-    protected function saveUpdate (EntityInterface $entity): void {
260
+    protected function saveUpdate(EntityInterface $entity): void {
261 261
         $this->cache(__FUNCTION__, function() {
262 262
             $slots = SQL::slotsEqual(array_keys($this->columns));
263 263
             unset($slots['id']);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      * @param array $columns Defaults to all columns.
273 273
      * @return Select
274 274
      */
275
-    public function select (array $columns = []): Select {
275
+    public function select(array $columns = []): Select {
276 276
         return parent::select($columns)->setFetcher(function(Statement $statement) {
277 277
             return $this->fetchAll($statement);
278 278
         });
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @param EntityInterface $proto
283 283
      * @return $this
284 284
      */
285
-    public function setProto (EntityInterface $proto) {
285
+    public function setProto(EntityInterface $proto) {
286 286
         $this->proto = $proto;
287 287
         return $this;
288 288
     }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      * @param EntityInterface $entity
292 292
      * @param array $values
293 293
      */
294
-    protected function setValues (EntityInterface $entity, array $values): void {
294
+    protected function setValues(EntityInterface $entity, array $values): void {
295 295
         foreach ($values as $name => $value) {
296 296
             settype($value, $this->types[$name]);
297 297
             $this->properties[$name]->setValue($entity, $value);
Please login to merge, or discard this patch.