Passed
Push — master ( c9f558...8b0690 )
by y
01:31
created
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
@@ -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/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 mixed $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 mixed $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 mixed $offset
47 47
      * @param mixed $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 mixed $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/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/Record.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->class = $class;
67 67
         try {
68 68
             $class = new ReflectionClass($class);
69
-        }
70
-        catch (ReflectionException $exception) {
69
+        } catch (ReflectionException $exception) {
71 70
             throw new LogicException('Unexpected ReflectionException', 0, $exception);
72 71
         }
73 72
         $this->proto = $class->newInstanceWithoutConstructor();
@@ -84,8 +83,7 @@  discard block
 block discarded – undo
84 83
                 if (preg_match('/@var\s+(?<type>[a-z]+)[\s$]/', $doc, $match)) {
85 84
                     $types[$name] = $match['type'];
86 85
                 }
87
-            }
88
-            elseif (preg_match('/@eav\s+(?<table>\S+)/', $doc, $match)) {
86
+            } elseif (preg_match('/@eav\s+(?<table>\S+)/', $doc, $match)) {
89 87
                 $eav[$name] = $match['table'];
90 88
                 $this->properties[$name] = $property;
91 89
             }
@@ -213,8 +211,7 @@  discard block
 block discarded – undo
213 211
     public function save (EntityInterface $entity): int {
214 212
         if (!$entity->getId()) {
215 213
             $this->saveInsert($entity);
216
-        }
217
-        else {
214
+        } else {
218 215
             $this->saveUpdate($entity);
219 216
         }
220 217
         $this->saveEav($entity);
Please login to merge, or discard this 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.
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.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/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.