@@ -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 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $to Migration sequence identifier, or `null` to step down once. |
46 | 46 | * @return null|string The resulting current sequence identifier. |
47 | 47 | */ |
48 | - public function down (string $to = null): ?string { |
|
48 | + public function down(string $to = null): ?string { |
|
49 | 49 | return $this->db->transact(function() use ($to) { |
50 | 50 | $current = $this->getCurrent(); |
51 | 51 | // walk newest to oldest |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return null|string |
74 | 74 | */ |
75 | - public function getCurrent (): ?string { |
|
75 | + public function getCurrent(): ?string { |
|
76 | 76 | return $this->getTable()['sequence']['max']; |
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - final public function getDir (): string { |
|
82 | + final public function getDir(): string { |
|
83 | 83 | return $this->dir; |
84 | 84 | } |
85 | 85 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param array $spec |
88 | 88 | * @return MigrationInterface |
89 | 89 | */ |
90 | - protected function getMigration (string $file) { |
|
90 | + protected function getMigration(string $file) { |
|
91 | 91 | $migration = include "{$file}"; |
92 | 92 | assert($migration instanceof MigrationInterface); |
93 | 93 | return $migration; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return Table |
100 | 100 | */ |
101 | - public function getTable () { |
|
101 | + public function getTable() { |
|
102 | 102 | return $this->table ??= ($this->db['__migrations__'] ?? |
103 | 103 | $this->db->getSchema()->createTable('__migrations__', [ |
104 | 104 | 'sequence' => Schema::T_STRING_STRICT | Schema::I_PRIMARY |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string[] [ sequence => file ] |
113 | 113 | */ |
114 | - protected function glob () { |
|
114 | + protected function glob() { |
|
115 | 115 | $files = []; |
116 | 116 | foreach (glob("{$this->dir}/*.php") as $file) { |
117 | 117 | $files[basename($file, '.php')] = $file; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param null|string $to Migration sequence identifier, or `null` for all upgrades. |
126 | 126 | * @return null|string The resulting current sequence identifier. |
127 | 127 | */ |
128 | - public function up (string $to = null): ?string { |
|
128 | + public function up(string $to = null): ?string { |
|
129 | 129 | return $this->db->transact(function() use ($to) { |
130 | 130 | $current = $this->getCurrent(); |
131 | 131 | // walk oldest to newest |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | private DB $db; |
28 | 28 | |
29 | - public function __construct (array $argv, array $opt) { |
|
29 | + public function __construct(array $argv, array $opt) { |
|
30 | 30 | $this->argv = $argv; |
31 | 31 | $opt['connection'] ??= 'default'; |
32 | 32 | $opt['config'] ??= 'db.config.php'; |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | $this->db->setLogger(fn($sql) => $this->_stdout($sql) and $realLogger($sql)); |
37 | 37 | } |
38 | 38 | |
39 | - private function _stderr (string $text): void { |
|
39 | + private function _stderr(string $text): void { |
|
40 | 40 | fputs(STDERR, "{$text}\n\n"); |
41 | 41 | } |
42 | 42 | |
43 | - private function _stdout (string $text): void { |
|
43 | + private function _stdout(string $text): void { |
|
44 | 44 | echo "{$text}\n\n"; |
45 | 45 | } |
46 | 46 | |
47 | - private function _usage_exit (): void { |
|
47 | + private function _usage_exit(): void { |
|
48 | 48 | $this->_stderr(<<< USAGE |
49 | 49 | |
50 | 50 | $ php {$this->argv[0]} [OPTIONS] ACTION |
@@ -301,13 +301,4 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function down (\$schema) |
303 | 303 | { |
304 | - {$down} |
|
305 | - } |
|
306 | - |
|
307 | - }; |
|
308 | - |
|
309 | - MIGRATION |
|
310 | - ); |
|
311 | - } |
|
312 | - |
|
313 | -})->_exec(); |
|
304 | + {$down} |
|
314 | 305 | \ No newline at end of file |