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