Passed
Push — master ( 5d6c6e...7e3b1d )
by y
01:51
created
src/DB.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param string $password
60 60
      * @param array $options
61 61
      */
62
-    public function __construct ($dsn, $username = null, $password = null, $options = null) {
62
+    public function __construct($dsn, $username = null, $password = null, $options = null) {
63 63
         parent::__construct($dsn, $username, $password, $options);
64 64
         $this->driver = $this->getAttribute(self::ATTR_DRIVER_NAME);
65 65
         $this->setAttribute(self::ATTR_DEFAULT_FETCH_MODE, self::FETCH_ASSOC);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return string
83 83
      */
84
-    final public function __toString () {
84
+    final public function __toString() {
85 85
         return $this->driver;
86 86
     }
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param string $sql
92 92
      * @return int
93 93
      */
94
-    public function exec ($sql): int {
94
+    public function exec($sql): int {
95 95
         $this->logger->__invoke($sql);
96 96
         return parent::exec($sql);
97 97
     }
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
      * @param mixed ...$args
108 108
      * @return mixed
109 109
      */
110
-    public function factory (string $class, ...$args) {
110
+    public function factory(string $class, ...$args) {
111 111
         return new $class($this, ...$args);
112 112
     }
113 113
 
114 114
     /**
115 115
      * @return string
116 116
      */
117
-    final public function getDriver (): string {
117
+    final public function getDriver(): string {
118 118
         return $this->driver;
119 119
     }
120 120
 
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
      * @param string $interface
125 125
      * @return Junction
126 126
      */
127
-    public function getJunction ($interface) {
127
+    public function getJunction($interface) {
128 128
         return $this->junctions[$interface] ??= Junction::fromInterface($this, $interface);
129 129
     }
130 130
 
131 131
     /**
132 132
      * @return Closure
133 133
      */
134
-    public function getLogger () {
134
+    public function getLogger() {
135 135
         return $this->logger;
136 136
     }
137 137
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      * @param string|EntityInterface $class
142 142
      * @return Record
143 143
      */
144
-    public function getRecord ($class) {
144
+    public function getRecord($class) {
145 145
         if (is_object($class)) {
146 146
             $class = get_class($class);
147 147
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      * @param string $name
153 153
      * @return null|Table
154 154
      */
155
-    public function getTable (string $name) {
155
+    public function getTable(string $name) {
156 156
         if (!isset($this->tables[$name])) {
157 157
             if ($this->isSQLite()) {
158 158
                 $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll();
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
     /**
175 175
      * @return bool
176 176
      */
177
-    final public function isMySQL (): bool {
177
+    final public function isMySQL(): bool {
178 178
         return $this->driver === 'mysql';
179 179
     }
180 180
 
181 181
     /**
182 182
      * @return bool
183 183
      */
184
-    final public function isPostgreSQL (): bool {
184
+    final public function isPostgreSQL(): bool {
185 185
         return $this->driver === 'pgsql';
186 186
     }
187 187
 
188 188
     /**
189 189
      * @return bool
190 190
      */
191
-    final public function isSQLite (): bool {
191
+    final public function isSQLite(): bool {
192 192
         return $this->driver === 'sqlite';
193 193
     }
194 194
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      * @param mixed $b
210 210
      * @return Predicate
211 211
      */
212
-    public function match ($a, $b) {
212
+    public function match($a, $b) {
213 213
         if ($b instanceof Closure) {
214 214
             return $b->__invoke($a, $this);
215 215
         }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * @param string $table
232 232
      * @return bool
233 233
      */
234
-    final public function offsetExists ($table): bool {
234
+    final public function offsetExists($table): bool {
235 235
         return (bool)$this->getTable($table);
236 236
     }
237 237
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      * @param string $table
242 242
      * @return null|Table
243 243
      */
244
-    final public function offsetGet ($table) {
244
+    final public function offsetGet($table) {
245 245
         return $this->getTable($table);
246 246
     }
247 247
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @param $value
251 251
      * @throws LogicException
252 252
      */
253
-    final public function offsetSet ($offset, $value) {
253
+    final public function offsetSet($offset, $value) {
254 254
         throw new LogicException('Raw table access is immutable.');
255 255
     }
256 256
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      * @param $offset
259 259
      * @throws LogicException
260 260
      */
261
-    final public function offsetUnset ($offset) {
261
+    final public function offsetUnset($offset) {
262 262
         throw new LogicException('Raw table access is immutable.');
263 263
     }
264 264
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      * @param array $options
270 270
      * @return Statement
271 271
      */
272
-    public function prepare ($sql, $options = []) {
272
+    public function prepare($sql, $options = []) {
273 273
         $this->logger->__invoke($sql);
274 274
         /** @var Statement $statement */
275 275
         $statement = parent::prepare($sql, $options);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      * @param array $ctorargs Optional.
286 286
      * @return Statement
287 287
      */
288
-    public function query ($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
288
+    public function query($sql, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = []) {
289 289
         $this->logger->__invoke($sql);
290 290
         /** @var Statement $statement */
291 291
         $statement = parent::query(...func_get_args());
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * @param int $type Ignored.
304 304
      * @return string|ExpressionInterface
305 305
      */
306
-    public function quote ($value, $type = self::PARAM_STR) {
306
+    public function quote($value, $type = self::PARAM_STR) {
307 307
         if ($value instanceof ExpressionInterface) {
308 308
             return $value;
309 309
         }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      * @param array $values
324 324
      * @return string[]
325 325
      */
326
-    public function quoteArray (array $values) {
326
+    public function quoteArray(array $values) {
327 327
         return array_map([$this, 'quote'], $values);
328 328
     }
329 329
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
      * @param array $values
334 334
      * @return string
335 335
      */
336
-    public function quoteList (array $values): string {
336
+    public function quoteList(array $values): string {
337 337
         return implode(',', $this->quoteArray($values));
338 338
     }
339 339
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
      * @param EntityInterface $entity
344 344
      * @return int ID
345 345
      */
346
-    public function save (EntityInterface $entity): int {
346
+    public function save(EntityInterface $entity): int {
347 347
         return $this->getRecord($entity)->save($entity);
348 348
     }
349 349
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
      * @param Junction $junction
353 353
      * @return $this
354 354
      */
355
-    public function setJunction (string $interface, Junction $junction) {
355
+    public function setJunction(string $interface, Junction $junction) {
356 356
         $this->junctions[$interface] = $junction;
357 357
         return $this;
358 358
     }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
      * @param Closure $logger
362 362
      * @return $this
363 363
      */
364
-    public function setLogger (Closure $logger) {
364
+    public function setLogger(Closure $logger) {
365 365
         $this->logger = $logger;
366 366
         return $this;
367 367
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
      * @param Record $record
372 372
      * @return $this
373 373
      */
374
-    public function setRecord (string $class, Record $record) {
374
+    public function setRecord(string $class, Record $record) {
375 375
         $this->records[$class] = $record;
376 376
         return $this;
377 377
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -157,8 +157,7 @@
 block discarded – undo
157 157
             if ($this->isSQLite()) {
158 158
                 $info = $this->query("PRAGMA table_info({$this->quote($name)})")->fetchAll();
159 159
                 $cols = array_column($info, 'name');
160
-            }
161
-            else {
160
+            } else {
162 161
                 $cols = $this->query(
163 162
                     "SELECT column_name FROM information_schema.tables WHERE table_name = {$this->quote($name)}"
164 163
                 )->fetchAll(self::FETCH_COLUMN);
Please login to merge, or discard this patch.
src/DB/Junction.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param string $interface
32 32
      * @return Junction
33 33
      */
34
-    public static function fromInterface (DB $db, string $interface) {
34
+    public static function fromInterface(DB $db, string $interface) {
35 35
         try {
36 36
             $ref = new ReflectionClass($interface);
37 37
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param string $table
55 55
      * @param string[] $classes
56 56
      */
57
-    public function __construct (DB $db, string $table, array $classes) {
57
+    public function __construct(DB $db, string $table, array $classes) {
58 58
         parent::__construct($db, $table, array_keys($classes));
59 59
         $this->classes = $classes;
60 60
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param array $match Keyed by junction column.
69 69
      * @return Select
70 70
      */
71
-    public function find (string $key, array $match = []) {
71
+    public function find(string $key, array $match = []) {
72 72
         $record = $this->db->getRecord($this->classes[$key]);
73 73
         $select = $record->select();
74 74
         $select->join($this, $this[$key]->isEqual($record['id']));
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param int[] $ids Keyed by column.
85 85
      * @return int Rows affected.
86 86
      */
87
-    public function link (array $ids): int {
87
+    public function link(array $ids): int {
88 88
         $statement = $this->cache(__FUNCTION__, function() {
89 89
             $columns = implode(',', array_keys($this->columns));
90 90
             $slots = implode(',', SQL::slots(array_keys($this->columns)));
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @param array $ids Keyed by Column
109 109
      * @return int Rows affected
110 110
      */
111
-    public function unlink (array $ids): int {
111
+    public function unlink(array $ids): int {
112 112
         return $this->delete($ids);
113 113
     }
114 114
 }
115 115
\ No newline at end of file
Please login to merge, or discard this patch.