@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * @param \PinkCrab\Table_Builder\Schema $schema |
88 | 88 | * @return self |
89 | 89 | */ |
90 | - public static function new_from_schema( Schema $schema ): self { |
|
90 | + public static function new_from_schema(Schema $schema): self { |
|
91 | 91 | return new self( |
92 | 92 | $schema->get_table_name(), |
93 | - self::compose_column_hash( $schema ), |
|
93 | + self::compose_column_hash($schema), |
|
94 | 94 | false, |
95 | 95 | new DateTimeImmutable(), |
96 | 96 | new DateTimeImmutable() |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param \DateTimeImmutable|null $updated_on |
104 | 104 | * @return self |
105 | 105 | */ |
106 | - public function as_updated( Schema $schema, ?DateTimeImmutable $updated_on = null ): self { |
|
106 | + public function as_updated(Schema $schema, ?DateTimeImmutable $updated_on = null): self { |
|
107 | 107 | return new self( |
108 | 108 | $this->table_name(), |
109 | - self::compose_column_hash( $schema ), |
|
109 | + self::compose_column_hash($schema), |
|
110 | 110 | $this->is_seeded(), |
111 | 111 | $this->created_on(), |
112 | 112 | $updated_on ?? new DateTimeImmutable() |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param \DateTimeImmutable|null $updated_on |
120 | 120 | * @return self |
121 | 121 | */ |
122 | - public function as_seeded( ?DateTimeImmutable $updated_on = null ): self { |
|
122 | + public function as_seeded(?DateTimeImmutable $updated_on = null): self { |
|
123 | 123 | return new self( |
124 | 124 | $this->table_name(), |
125 | 125 | $this->schema_hash(), |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param \PinkCrab\Table_Builder\Schema $schema |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - public static function compose_column_hash( Schema $schema ): string { |
|
138 | + public static function compose_column_hash(Schema $schema): string { |
|
139 | 139 | $export = array( |
140 | 140 | 'name' => $schema->get_table_name(), |
141 | 141 | 'columns' => $schema->get_columns(), |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'foreign_keys' => $schema->get_foreign_keys(), |
144 | 144 | ); |
145 | 145 | |
146 | - return md5( \serialize( $export ) ?: $schema->get_table_name() ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize, Serialised to preserve types |
|
146 | + return md5(\serialize($export) ?: $schema->get_table_name()); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize, Serialised to preserve types |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** GETTERS */ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected $migration_details = array(); |
47 | 47 | |
48 | - public function __construct( string $option_key = null ) { |
|
48 | + public function __construct(string $option_key = null) { |
|
49 | 49 | $this->option_key = $option_key ?? 'pinkcrab_migration_log'; |
50 | 50 | $this->set_migration_details(); |
51 | 51 | } |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | * @throws InvalidArgumentException If can not unserialize |
58 | 58 | */ |
59 | 59 | protected function set_migration_details(): void { |
60 | - $migrations = get_option( $this->option_key, null ); |
|
60 | + $migrations = get_option($this->option_key, null); |
|
61 | 61 | |
62 | - if ( $migrations === null ) { |
|
62 | + if ($migrations === null) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | 66 | // Handle errors as exceptions. |
67 | 67 | set_error_handler( // phpcs:ignore |
68 | - function ( int $errno, string $errstr ) { // phpcs:ignore |
|
69 | - throw new InvalidArgumentException( 'Migration details as unserialize from options, failed to be decoded.' ); |
|
68 | + function(int $errno, string $errstr) { // phpcs:ignore |
|
69 | + throw new InvalidArgumentException('Migration details as unserialize from options, failed to be decoded.'); |
|
70 | 70 | } |
71 | 71 | ); |
72 | - $migrations = \unserialize( $migrations ); // phpcs:ignore |
|
72 | + $migrations = \unserialize($migrations); // phpcs:ignore |
|
73 | 73 | restore_error_handler(); |
74 | 74 | |
75 | 75 | $this->migration_details = $migrations; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @param \PinkCrab\Table_Builder\Schema $schema |
82 | 82 | * @return boolean |
83 | 83 | */ |
84 | - public function has_migration( Schema $schema ): bool { |
|
85 | - return array_key_exists( $schema->get_table_name(), $this->migration_details ); |
|
84 | + public function has_migration(Schema $schema): bool { |
|
85 | + return array_key_exists($schema->get_table_name(), $this->migration_details); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return \PinkCrab\DB_Migration\Log\Migration_Log|null |
92 | 92 | */ |
93 | - public function get_migration( Schema $schema ): ?Migration_Log { |
|
94 | - return $this->has_migration( $schema ) |
|
93 | + public function get_migration(Schema $schema): ?Migration_Log { |
|
94 | + return $this->has_migration($schema) |
|
95 | 95 | ? $this->migration_details[ $schema->get_table_name() ] |
96 | 96 | : null; |
97 | 97 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param \PinkCrab\Table_Builder\Schema $schema |
103 | 103 | * @return bool |
104 | 104 | */ |
105 | - public function can_migrate( Schema $schema ): bool { |
|
106 | - return ! $this->check_hash( $schema ); |
|
105 | + public function can_migrate(Schema $schema): bool { |
|
106 | + return ! $this->check_hash($schema); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param \PinkCrab\Table_Builder\Schema $schema |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | - public function is_seeded( Schema $schema ): bool { |
|
116 | - return $this->has_migration( $schema ) |
|
115 | + public function is_seeded(Schema $schema): bool { |
|
116 | + return $this->has_migration($schema) |
|
117 | 117 | && $this->migration_details[ $schema->get_table_name() ]->is_seeded(); |
118 | 118 | } |
119 | 119 | |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * @param \PinkCrab\Table_Builder\Schema $schema |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | - public function check_hash( Schema $schema ): bool { |
|
126 | + public function check_hash(Schema $schema): bool { |
|
127 | 127 | // If table doesnt exist, return false; |
128 | - if ( ! $this->has_migration( $schema ) ) { |
|
128 | + if ( ! $this->has_migration($schema)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $schema_hash = Migration_Log::compose_column_hash( $schema ); |
|
132 | + $schema_hash = Migration_Log::compose_column_hash($schema); |
|
133 | 133 | $migration = $this->migration_details[ $schema->get_table_name() ]; |
134 | - return strcmp( $schema_hash, $migration->schema_hash() ) === 0; |
|
134 | + return strcmp($schema_hash, $migration->schema_hash()) === 0; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -145,20 +145,20 @@ discard block |
||
145 | 145 | * @param \PinkCrab\Table_Builder\Schema $schema |
146 | 146 | * @return self |
147 | 147 | */ |
148 | - public function upsert_migration( Schema $schema ): self { |
|
148 | + public function upsert_migration(Schema $schema): self { |
|
149 | 149 | // Update if table exists and we have a new schema defined. |
150 | - if ( $this->has_migration( $schema ) |
|
151 | - && ! $this->check_hash( $schema ) ) { |
|
150 | + if ($this->has_migration($schema) |
|
151 | + && ! $this->check_hash($schema)) { |
|
152 | 152 | $this->migration_details[ $schema->get_table_name() ] = |
153 | - $this->migration_details[ $schema->get_table_name() ]->as_updated( $schema ); |
|
153 | + $this->migration_details[ $schema->get_table_name() ]->as_updated($schema); |
|
154 | 154 | |
155 | 155 | $this->save(); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // If a new hash. |
159 | - if ( $this->has_migration( $schema ) === false ) { |
|
159 | + if ($this->has_migration($schema) === false) { |
|
160 | 160 | $this->migration_details[ $schema->get_table_name() ] = |
161 | - Migration_Log::new_from_schema( $schema ); |
|
161 | + Migration_Log::new_from_schema($schema); |
|
162 | 162 | |
163 | 163 | $this->save(); |
164 | 164 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param \PinkCrab\Table_Builder\Schema $schema |
173 | 173 | * @return self |
174 | 174 | */ |
175 | - public function remove_migration( Schema $schema ): self { |
|
176 | - if ( $this->has_migration( $schema ) ) { |
|
177 | - unset( $this->migration_details[ $schema->get_table_name() ] ); |
|
175 | + public function remove_migration(Schema $schema): self { |
|
176 | + if ($this->has_migration($schema)) { |
|
177 | + unset($this->migration_details[ $schema->get_table_name() ]); |
|
178 | 178 | |
179 | 179 | $this->save(); |
180 | 180 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @param \PinkCrab\Table_Builder\Schema $schema |
188 | 188 | * @return self |
189 | 189 | */ |
190 | - public function mark_table_seeded( Schema $schema ): self { |
|
191 | - if ( ! $this->is_seeded( $schema ) ) { |
|
190 | + public function mark_table_seeded(Schema $schema): self { |
|
191 | + if ( ! $this->is_seeded($schema)) { |
|
192 | 192 | $this->migration_details[ $schema->get_table_name() ] = |
193 | 193 | $this->migration_details[ $schema->get_table_name() ]->as_seeded(); |
194 | 194 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | */ |
206 | 206 | protected function save(): void { |
207 | - \update_option( $this->option_key, serialize( $this->migration_details ) ); // phpcs:ignore |
|
207 | + \update_option($this->option_key, serialize($this->migration_details)); // phpcs:ignore |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | * @throws Exception If table name not defiend. |
54 | 54 | */ |
55 | 55 | public function __construct() { |
56 | - $this->schema = new Schema( $this->table_name, array( $this, 'schema' ) ); |
|
57 | - $this->seed_data = $this->seed( array() ); |
|
56 | + $this->schema = new Schema($this->table_name, array($this, 'schema')); |
|
57 | + $this->seed_data = $this->seed(array()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param Schema $schema_config |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - abstract public function schema( Schema $schema_config ): void; |
|
66 | + abstract public function schema(Schema $schema_config): void; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Defines the data to be seeded. |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param array<string, mixed> $seeds |
72 | 72 | * @return array<string, mixed> |
73 | 73 | */ |
74 | - public function seed( array $seeds ): array { |
|
74 | + public function seed(array $seeds): array { |
|
75 | 75 | return $seeds; |
76 | 76 | } |
77 | 77 |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * @return Migration_Exception |
37 | 37 | * @code 1 |
38 | 38 | */ |
39 | - public static function seed_column_doesnt_exist( string $column, string $table_name ): Migration_Exception { |
|
39 | + public static function seed_column_doesnt_exist(string $column, string $table_name): Migration_Exception { |
|
40 | 40 | return new Migration_Exception( |
41 | - \sprintf( 'Could not find column %s in %s schema definition', $column, $table_name ), |
|
41 | + \sprintf('Could not find column %s in %s schema definition', $column, $table_name), |
|
42 | 42 | 1 |
43 | 43 | ); |
44 | 44 | } |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | * @return Migration_Exception |
52 | 52 | * @code 2 |
53 | 53 | */ |
54 | - public static function failed_to_insert_seed( string $wpdb_error, string $table_name ): Migration_Exception { |
|
54 | + public static function failed_to_insert_seed(string $wpdb_error, string $table_name): Migration_Exception { |
|
55 | 55 | return new Migration_Exception( |
56 | - \sprintf( 'Could not insert seed into %s, failed with error: %s', $table_name, $wpdb_error ), |
|
56 | + \sprintf('Could not insert seed into %s, failed with error: %s', $table_name, $wpdb_error), |
|
57 | 57 | 2 |
58 | 58 | ); |
59 | 59 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @return Migration_Exception |
66 | 66 | * @code 3 |
67 | 67 | */ |
68 | - public static function failed_to_drop_table( string $table_name ): Migration_Exception { |
|
68 | + public static function failed_to_drop_table(string $table_name): Migration_Exception { |
|
69 | 69 | return new Migration_Exception( |
70 | - \sprintf( 'Failed to drop %d', $table_name ), |
|
70 | + \sprintf('Failed to drop %d', $table_name), |
|
71 | 71 | 3 |
72 | 72 | ); |
73 | 73 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected $migration_log; |
61 | 61 | |
62 | - public function __construct( Builder $builder, wpdb $wpdb, ?string $migration_log_key = null ) { |
|
62 | + public function __construct(Builder $builder, wpdb $wpdb, ?string $migration_log_key = null) { |
|
63 | 63 | $this->builder = $builder; |
64 | 64 | $this->wpdb = $wpdb; |
65 | - $this->migration_log = new Migration_Log_Manager( $migration_log_key ); |
|
65 | + $this->migration_log = new Migration_Log_Manager($migration_log_key); |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param \PinkCrab\DB_Migration\Database_Migration $migration |
82 | 82 | * @return self |
83 | 83 | */ |
84 | - public function add_migration( Database_Migration $migration ): self { |
|
84 | + public function add_migration(Database_Migration $migration): self { |
|
85 | 85 | $this->migrations[ $migration->get_table_name() ] = $migration; |
86 | 86 | return $this; |
87 | 87 | } |
@@ -101,22 +101,22 @@ discard block |
||
101 | 101 | * @param string ...$exlcude_table Table names to exclude. |
102 | 102 | * @return self |
103 | 103 | */ |
104 | - public function create_tables( string ...$exlcude_table ): self { |
|
104 | + public function create_tables(string ...$exlcude_table): self { |
|
105 | 105 | |
106 | 106 | // Remove exlcluded tables. |
107 | 107 | $to_create = array_filter( |
108 | 108 | $this->migrations, |
109 | - function( Database_Migration $migration ) use ( $exlcude_table ): bool { |
|
110 | - return ! in_array( $migration->get_table_name(), $exlcude_table, true ) |
|
111 | - && $this->migration_log->can_migrate( $migration->get_schema() ); |
|
109 | + function(Database_Migration $migration) use ($exlcude_table): bool { |
|
110 | + return ! in_array($migration->get_table_name(), $exlcude_table, true) |
|
111 | + && $this->migration_log->can_migrate($migration->get_schema()); |
|
112 | 112 | } |
113 | 113 | ); |
114 | 114 | |
115 | 115 | // Upsert Tables. |
116 | - foreach ( $to_create as $migration ) { |
|
117 | - $result = $this->builder->create_table( $migration->get_schema() ); |
|
118 | - if ( $result === true ) { |
|
119 | - $this->migration_log->upsert_migration( $migration->get_schema() ); |
|
116 | + foreach ($to_create as $migration) { |
|
117 | + $result = $this->builder->create_table($migration->get_schema()); |
|
118 | + if ($result === true) { |
|
119 | + $this->migration_log->upsert_migration($migration->get_schema()); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | * @param string ...$exlcude_table Table names to exclude. |
131 | 131 | * @return self |
132 | 132 | */ |
133 | - public function seed_tables( string ...$exlcude_table ): self { |
|
133 | + public function seed_tables(string ...$exlcude_table): self { |
|
134 | 134 | |
135 | 135 | // Remove exlcluded tables. |
136 | 136 | $to_seed = array_filter( |
137 | 137 | $this->migrations, |
138 | - function( Database_Migration $migration ) use ( $exlcude_table ): bool { |
|
139 | - return ! in_array( $migration->get_table_name(), $exlcude_table, true ) |
|
140 | - && ! $this->migration_log->is_seeded( $migration->get_schema() ); |
|
138 | + function(Database_Migration $migration) use ($exlcude_table): bool { |
|
139 | + return ! in_array($migration->get_table_name(), $exlcude_table, true) |
|
140 | + && ! $this->migration_log->is_seeded($migration->get_schema()); |
|
141 | 141 | } |
142 | 142 | ); |
143 | 143 | |
144 | - $seeder = new Migration_Seeder( $this->wpdb ); |
|
144 | + $seeder = new Migration_Seeder($this->wpdb); |
|
145 | 145 | |
146 | - foreach ( $to_seed as $migration ) { |
|
147 | - $row = $seeder->seed( $migration->get_schema(), $migration->get_seeds() ); |
|
148 | - if ( count( $row ) !== 0 ) { |
|
149 | - $this->migration_log->mark_table_seeded( $migration->get_schema() ); |
|
146 | + foreach ($to_seed as $migration) { |
|
147 | + $row = $seeder->seed($migration->get_schema(), $migration->get_seeds()); |
|
148 | + if (count($row) !== 0) { |
|
149 | + $this->migration_log->mark_table_seeded($migration->get_schema()); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -159,26 +159,26 @@ discard block |
||
159 | 159 | * @param string ...$exlcude_table Table names to exclude. |
160 | 160 | * @return self |
161 | 161 | */ |
162 | - public function drop_tables( string ...$exlcude_table ): self { |
|
162 | + public function drop_tables(string ...$exlcude_table): self { |
|
163 | 163 | // Remove exlcluded tables. |
164 | 164 | $to_seed = array_filter( |
165 | 165 | $this->migrations, |
166 | - function( Database_Migration $migration ) use ( $exlcude_table ): bool { |
|
167 | - return ! in_array( $migration->get_table_name(), $exlcude_table, true ); |
|
166 | + function(Database_Migration $migration) use ($exlcude_table): bool { |
|
167 | + return ! in_array($migration->get_table_name(), $exlcude_table, true); |
|
168 | 168 | } |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $to_seed as $migration ) { |
|
171 | + foreach ($to_seed as $migration) { |
|
172 | 172 | |
173 | - $result = $this->builder->drop_table( $migration->get_schema() ); |
|
173 | + $result = $this->builder->drop_table($migration->get_schema()); |
|
174 | 174 | |
175 | 175 | // Throw exception if fails. |
176 | - if ( $result === false ) { |
|
177 | - throw Migration_Exception::failed_to_drop_table( $migration->get_table_name() ); |
|
176 | + if ($result === false) { |
|
177 | + throw Migration_Exception::failed_to_drop_table($migration->get_table_name()); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Remove mitation from log. |
181 | - $this->migration_log->remove_migration( $migration->get_schema() ); |
|
181 | + $this->migration_log->remove_migration($migration->get_schema()); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $this; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected $wpdb; |
38 | 38 | |
39 | - public function __construct( wpdb $wpdb ) { |
|
39 | + public function __construct(wpdb $wpdb) { |
|
40 | 40 | $this->wpdb = $wpdb; |
41 | 41 | } |
42 | 42 | |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param array<array<string, mixed>> $seed_data |
48 | 48 | * @return array<string, int> |
49 | 49 | */ |
50 | - public function seed( Schema $schema, array $seed_data ): array { |
|
50 | + public function seed(Schema $schema, array $seed_data): array { |
|
51 | 51 | $results = array(); |
52 | 52 | |
53 | - foreach ( $seed_data as $key => $seed ) { |
|
54 | - $results[ $key ] = $this->insert_seed( $schema, $seed ); |
|
53 | + foreach ($seed_data as $key => $seed) { |
|
54 | + $results[ $key ] = $this->insert_seed($schema, $seed); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $results; |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @return int The new row ID. |
66 | 66 | * @throws Migration_Exception |
67 | 67 | */ |
68 | - protected function insert_seed( Schema $schema, array $seed ): int { |
|
68 | + protected function insert_seed(Schema $schema, array $seed): int { |
|
69 | 69 | // Get format for each column based on the type. |
70 | 70 | $format = array_map( |
71 | - function( string $column_name ) use ( $schema ): string { |
|
72 | - return $this->column_type( $schema, $column_name ); |
|
71 | + function(string $column_name) use ($schema): string { |
|
72 | + return $this->column_type($schema, $column_name); |
|
73 | 73 | }, |
74 | - array_keys( $seed ) |
|
74 | + array_keys($seed) |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | $this->wpdb->insert( |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Check any errors inserting. |
84 | - if ( $this->wpdb->last_error !== '' ) { |
|
85 | - throw Migration_Exception::failed_to_insert_seed( $this->wpdb->last_error, $schema->get_table_name() ); |
|
84 | + if ($this->wpdb->last_error !== '') { |
|
85 | + throw Migration_Exception::failed_to_insert_seed($this->wpdb->last_error, $schema->get_table_name()); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return $this->wpdb->insert_id; |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * @return string |
97 | 97 | * @throws Migration_Exception If a column cant be found. |
98 | 98 | */ |
99 | - protected function column_type( Schema $schema, string $column ): string { |
|
99 | + protected function column_type(Schema $schema, string $column): string { |
|
100 | 100 | $schema_columns = $schema->get_columns(); |
101 | 101 | |
102 | 102 | // If colum doesnt exist, thorw exception. |
103 | - if ( ! array_key_exists( $column, $schema_columns ) ) { |
|
104 | - throw Migration_Exception::seed_column_doesnt_exist( $column, $schema->get_table_name() ); |
|
103 | + if ( ! array_key_exists($column, $schema_columns)) { |
|
104 | + throw Migration_Exception::seed_column_doesnt_exist($column, $schema->get_table_name()); |
|
105 | 105 | } |
106 | 106 | |
107 | - return $this->column_type_format( $schema_columns[ $column ]->get_type() ?? '' ); |
|
107 | + return $this->column_type_format($schema_columns[ $column ]->get_type() ?? ''); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * @param string $type |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - protected function column_type_format( string $type ): string { |
|
117 | - switch ( \strtoupper( $type ) ) { |
|
116 | + protected function column_type_format(string $type): string { |
|
117 | + switch (\strtoupper($type)) { |
|
118 | 118 | case 'CHAR': |
119 | 119 | case 'VARCHAR': |
120 | 120 | case 'BINARY': |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | * @param \wpdb|null $wpdb Can pass custom wpdb instance |
39 | 39 | * @return Migration_Manager |
40 | 40 | */ |
41 | - public static function manager_with_db_delta( ?string $option_key = null, ?\wpdb $wpdb = null ): Migration_Manager { |
|
42 | - if ( $wpdb === null ) { |
|
41 | + public static function manager_with_db_delta(?string $option_key = null, ?\wpdb $wpdb = null): Migration_Manager { |
|
42 | + if ($wpdb === null) { |
|
43 | 43 | global $wpdb; |
44 | 44 | } |
45 | 45 | |
46 | - $builder = new Builder( new DB_Delta_Engine( $wpdb ) ); |
|
47 | - return new Migration_Manager( $builder, $wpdb, $option_key ); |
|
46 | + $builder = new Builder(new DB_Delta_Engine($wpdb)); |
|
47 | + return new Migration_Manager($builder, $wpdb, $option_key); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param string|null $option_key |
56 | 56 | * @return \PinkCrab\DB_Migration\Log\Migration_Log_Manager |
57 | 57 | */ |
58 | - public static function migration_log( ?string $option_key = null ): Migration_Log_Manager { |
|
59 | - return new Migration_Log_Manager( $option_key ); |
|
58 | + public static function migration_log(?string $option_key = null): Migration_Log_Manager { |
|
59 | + return new Migration_Log_Manager($option_key); |
|
60 | 60 | } |
61 | 61 | } |