@@ -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