Conditions | 7 |
Paths | 40 |
Total Lines | 80 |
Code Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
42 | * @return array |
||
43 | */ |
||
44 | public function getExportOptions(string $database, string $table = ''): array |
||
45 | { |
||
46 | $results = [ |
||
47 | 'options' => $this->getBaseOptions($database, $table), |
||
48 | 'prefixes' => [], |
||
49 | 'labels' => [ |
||
50 | 'export' => $this->trans->lang('Export'), |
||
51 | ], |
||
52 | ]; |
||
53 | if (($database)) { |
||
54 | $results['tables'] = $this->getDbTables(); |
||
55 | } else { |
||
56 | $results['databases'] = $this->getDatabases(); |
||
57 | } |
||
58 | return $results; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Dump routines and events in the connected database |
||
63 | * |
||
64 | * @param string $database The database name |
||
65 | * |
||
66 | * @return void |
||
67 | */ |
||
68 | private function dumpRoutinesAndEvents(string $database) |
||
69 | { |
||
70 | // From dump.inc.php |
||
71 | $style = $this->options['db_style']; |
||
72 | $queries = []; |
||
73 | |||
74 | if ($this->options['routines']) { |
||
75 | $sql = 'SHOW FUNCTION STATUS WHERE Db = ' . $this->driver->quote($database); |
||
76 | foreach ($this->driver->rows($sql) as $row) { |
||
77 | $sql = 'SHOW CREATE FUNCTION ' . $this->driver->escapeId($row['Name']); |
||
78 | $create = $this->admin->removeDefiner($this->driver->result($sql, 2)); |
||
79 | $queries[] = $this->driver->setUtf8mb4($create); |
||
80 | if ($style != 'DROP+CREATE') { |
||
81 | $queries[] = 'DROP FUNCTION IF EXISTS ' . $this->driver->escapeId($row['Name']) . ';;'; |
||
82 | } |
||
83 | $queries[] = "$create;;\n"; |
||
84 | } |
||
85 | $sql = 'SHOW PROCEDURE STATUS WHERE Db = ' . $this->driver->quote($database); |
||
86 | foreach ($this->driver->rows($sql) as $row) { |
||
87 | $sql = 'SHOW CREATE PROCEDURE ' . $this->driver->escapeId($row['Name']); |
||
88 | $create = $this->admin->removeDefiner($this->driver->result($sql, 2)); |
||
89 | $queries[] = $this->driver->setUtf8mb4($create); |
||
90 | if ($style != 'DROP+CREATE') { |
||
91 | $queries[] = 'DROP PROCEDURE IF EXISTS ' . $this->driver->escapeId($row['Name']) . ';;'; |
||
92 | } |
||
93 | $queries[] = "$create;;\n"; |
||
94 | } |
||
95 | } |
||
96 | |||
97 | if ($this->options['events']) { |
||
98 | foreach ($this->driver->rows('SHOW EVENTS') as $row) { |
||
99 | $sql = 'SHOW CREATE EVENT ' . $this->driver->escapeId($row['Name']); |
||
100 | $create = $this->admin->removeDefiner($this->driver->result($sql, 3)); |
||
101 | $queries[] = $this->driver->setUtf8mb4($create); |
||
102 | if ($style != 'DROP+CREATE') { |
||
103 | $queries[] = 'DROP EVENT IF EXISTS ' . $this->driver->escapeId($row['Name']) . ';;'; |
||
104 | } |
||
105 | $queries[] = "$create;;\n"; |
||
106 | } |
||
107 | } |
||
108 | |||
109 | if (count($queries) > 0) { |
||
110 | $this->queries[] = "DELIMITER ;;\n"; |
||
111 | foreach ($queries as $query) { |
||
112 | $this->queries[] = $query; |
||
113 | } |
||
114 | $this->queries[] = "DELIMITER ;;\n"; |
||
115 | } |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * @param string $table |
||
120 | * @param bool $dumpTable |
||
121 | * @param bool $dumpData |
||
122 | * |
||
297 |