Skip to content

Commit ce86994

Browse files
committed
format php files
1 parent fb644ce commit ce86994

2 files changed

Lines changed: 39 additions & 36 deletions

File tree

‎src/SQLite_Command.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ public function export( $args, $assoc_args ) {
142142
*
143143
* @when before_wp_load
144144
*/
145-
public function tables($args, $assoc_args) {
146-
if (!Base::get_sqlite_plugin_version()) {
147-
WP_CLI::error('The SQLite integration plugin is not installed or activated.');
145+
public function tables( $args, $assoc_args ) {
146+
if ( ! Base::get_sqlite_plugin_version() ) {
147+
WP_CLI::error( 'The SQLite integration plugin is not installed or activated.' );
148148
}
149149

150-
$tables = new Tables();
151-
$pattern = !empty($args) ? $args[0] : null;
152-
$tables->run($pattern, $assoc_args);
150+
$tables = new Tables();
151+
$pattern = ! empty( $args ) ? $args[0] : null;
152+
$tables->run( $pattern, $assoc_args );
153153
}
154154
}

‎src/Tables.php‎

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,44 @@ protected function get_pdo() {
3030
return $this->translator->get_pdo();
3131
}
3232

33-
/**
34-
* Lists all tables in the SQLite database.
35-
*
36-
* @param string|null $pattern Optional wildcard pattern to filter tables.
37-
* @param array $assoc_args Associative array of options.
38-
* @return void
39-
*/
40-
public function run($pattern = null, $assoc_args = []) {
41-
$pdo = $this->get_pdo();
33+
/**
34+
* Lists all tables in the SQLite database.
35+
*
36+
* @param string|null $pattern Optional wildcard pattern to filter tables.
37+
* @param array $assoc_args Associative array of options.
38+
* @return void
39+
*/
40+
public function run( $pattern = null, $assoc_args = [] ) {
41+
$pdo = $this->get_pdo();
4242

43-
// Get all tables
44-
$stmt = $pdo->query("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'");
45-
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
43+
// Get all tables
44+
$stmt = $pdo->query( "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'" );
45+
$tables = $stmt->fetchAll( PDO::FETCH_COLUMN );
4646

47-
// Filter tables if wildcard pattern is provided
48-
if ($pattern) {
49-
$sql_pattern = str_replace('?', '_', $pattern);
50-
$sql_pattern = str_replace('*', '%', $sql_pattern);
47+
// Filter tables if wildcard pattern is provided
48+
if ( $pattern ) {
49+
$sql_pattern = str_replace( '?', '_', $pattern );
50+
$sql_pattern = str_replace( '*', '%', $sql_pattern );
5151

52-
$tables = array_filter($tables, function($table) use ($pattern) {
53-
return fnmatch($pattern, $table, FNM_CASEFOLD);
54-
});
55-
}
52+
$tables = array_filter(
53+
$tables,
54+
function ( $table ) use ( $pattern ) {
55+
return fnmatch( $pattern, $table, FNM_CASEFOLD );
56+
}
57+
);
58+
}
5659

5760
// Remove system tables
58-
$tables_to_exclude = array('_mysql_data_types_cache');
59-
$tables = array_diff($tables, $tables_to_exclude);
61+
$tables_to_exclude = array( '_mysql_data_types_cache' );
62+
$tables = array_diff( $tables, $tables_to_exclude );
6063

61-
if (empty($tables)) {
62-
if ($pattern) {
63-
WP_CLI::error("No tables found matching: " . $pattern);
64-
} else {
65-
WP_CLI::error("No tables found in the database.");
66-
}
67-
}
64+
if ( empty( $tables ) ) {
65+
if ( $pattern ) {
66+
WP_CLI::error( 'No tables found matching: ' . $pattern );
67+
} else {
68+
WP_CLI::error( 'No tables found in the database.' );
69+
}
70+
}
6871

6972
$format = \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' );
7073

@@ -75,5 +78,5 @@ public function run($pattern = null, $assoc_args = []) {
7578
WP_CLI::line( $table );
7679
}
7780
}
78-
}
81+
}
7982
}

0 commit comments

Comments
 (0)