@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param DB $db |
| 35 | 35 | * @param string $dir |
| 36 | 36 | */ |
| 37 | - public function __construct (DB $db, string $dir) { |
|
| 37 | + public function __construct(DB $db, string $dir) { |
|
| 38 | 38 | $this->db = $db; |
| 39 | 39 | $this->dir = $dir; |
| 40 | 40 | $this->table ??= $db['__migrations__'] ?? $db->getSchema()->createTable('__migrations__', [ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $to Migration sequence identifier, or `null` to step down once. |
| 49 | 49 | * @return null|string The resulting current sequence identifier. |
| 50 | 50 | */ |
| 51 | - public function down (string $to = null): ?string { |
|
| 51 | + public function down(string $to = null): ?string { |
|
| 52 | 52 | return $this->db->transact(function() use ($to) { |
| 53 | 53 | $current = $this->getCurrent(); |
| 54 | 54 | // walk newest to oldest |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return null|string |
| 77 | 77 | */ |
| 78 | - public function getCurrent (): ?string { |
|
| 78 | + public function getCurrent(): ?string { |
|
| 79 | 79 | return $this->table['sequence']['max']; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - final public function getDir (): string { |
|
| 85 | + final public function getDir(): string { |
|
| 86 | 86 | return $this->dir; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param array $spec |
| 91 | 91 | * @return MigrationInterface |
| 92 | 92 | */ |
| 93 | - protected function getMigration (string $file) { |
|
| 93 | + protected function getMigration(string $file) { |
|
| 94 | 94 | $migration = include "{$file}"; |
| 95 | 95 | assert($migration instanceof MigrationInterface); |
| 96 | 96 | return $migration; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return string[] [ sequence => file ] |
| 103 | 103 | */ |
| 104 | - protected function glob () { |
|
| 104 | + protected function glob() { |
|
| 105 | 105 | $files = []; |
| 106 | 106 | foreach (glob("{$this->dir}/*.php") as $file) { |
| 107 | 107 | $files[basename($file, '.php')] = $file; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param null|string $to Migration sequence identifier, or `null` for all upgrades. |
| 116 | 116 | * @return null|string The resulting current sequence identifier. |
| 117 | 117 | */ |
| 118 | - public function up (string $to = null): ?string { |
|
| 118 | + public function up(string $to = null): ?string { |
|
| 119 | 119 | return $this->db->transact(function() use ($to) { |
| 120 | 120 | $current = $this->getCurrent(); |
| 121 | 121 | // walk oldest to newest |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param string $name |
| 48 | 48 | * @param string $qualifier |
| 49 | 49 | */ |
| 50 | - public function __construct (DB $db, string $name, string $qualifier = '') { |
|
| 50 | + public function __construct(DB $db, string $name, string $qualifier = '') { |
|
| 51 | 51 | $this->db = $db; |
| 52 | 52 | $this->name = $name; |
| 53 | 53 | $this->qualifier = $qualifier; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | - public function __toString () { |
|
| 61 | + public function __toString() { |
|
| 62 | 62 | if (strlen($this->qualifier)) { |
| 63 | 63 | return "{$this->qualifier}.{$this->name}"; |
| 64 | 64 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | - final public function getName (): string { |
|
| 71 | + final public function getName(): string { |
|
| 72 | 72 | return $this->name; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - final public function getQualifier (): string { |
|
| 78 | + final public function getQualifier(): string { |
|
| 79 | 79 | return $this->qualifier; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param mixed $value |
| 86 | 86 | * @return true |
| 87 | 87 | */ |
| 88 | - final public function offsetExists ($value) { |
|
| 88 | + final public function offsetExists($value) { |
|
| 89 | 89 | return true; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param string $aggregator |
| 99 | 99 | * @return null|string |
| 100 | 100 | */ |
| 101 | - public function offsetGet ($aggregator) { |
|
| 101 | + public function offsetGet($aggregator) { |
|
| 102 | 102 | $aggregator = preg_replace('/[ _()]/', '', $aggregator); // accept a variety of forms |
| 103 | 103 | $aggregator = $this->{$aggregator}(); // methods are not case sensitive |
| 104 | 104 | return Select::factory($this->db, $this->qualifier, [$aggregator])->getResult(); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param mixed $value |
| 112 | 112 | * @throws LogicException |
| 113 | 113 | */ |
| 114 | - final public function offsetSet ($offset, $value) { |
|
| 114 | + final public function offsetSet($offset, $value) { |
|
| 115 | 115 | throw new LogicException("Column aggregation is read-only"); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param mixed $offset |
| 122 | 122 | * @throws LogicException |
| 123 | 123 | */ |
| 124 | - final public function offsetUnset ($offset) { |
|
| 124 | + final public function offsetUnset($offset) { |
|
| 125 | 125 | throw new LogicException("Column aggregation is read-only"); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return Select|scalar[] |
| 132 | 132 | */ |
| 133 | - public function select () { |
|
| 133 | + public function select() { |
|
| 134 | 134 | return Select::factory($this->db, $this->qualifier, [$this->name]) |
| 135 | 135 | ->setFetcher(function(Statement $statement) { |
| 136 | 136 | while (false !== $value = $statement->fetchColumn()) { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $name |
| 148 | 148 | * @return $this |
| 149 | 149 | */ |
| 150 | - public function setName (string $name) { |
|
| 150 | + public function setName(string $name) { |
|
| 151 | 151 | $clone = clone $this; |
| 152 | 152 | $clone->name = $name; |
| 153 | 153 | return $clone; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $qualifier |
| 158 | 158 | * @return $this |
| 159 | 159 | */ |
| 160 | - public function setQualifier (string $qualifier) { |
|
| 160 | + public function setQualifier(string $qualifier) { |
|
| 161 | 161 | $clone = clone $this; |
| 162 | 162 | $clone->qualifier = $qualifier; |
| 163 | 163 | return $clone; |