Conditions | 11 |
Paths | 1024 |
Total Lines | 43 |
Code Lines | 26 |
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 |
||
68 | public function getDumpOptions(string $credentialFile) |
||
69 | { |
||
70 | $options = [ |
||
71 | "{$this->dumpCommandPath}mysqldump", |
||
72 | "--defaults-extra-file={$credentialFile}", |
||
73 | ]; |
||
74 | |||
75 | if ($this->dbName) { |
||
76 | $options['database'] = $this->dbName; |
||
77 | } |
||
78 | if ($this->socket) { |
||
79 | $options['socket'] = "--socket={$this->socket}"; |
||
80 | } |
||
81 | if ($this->skipComments) { |
||
82 | $options['skipComments'] = '--skip-comments'; |
||
83 | } |
||
84 | if (!$this->createTables) { |
||
85 | $options['createTables'] = '--no-create-info'; |
||
86 | } |
||
87 | if ($this->singleTransaction) { |
||
88 | $options['singleTransaction'] = '--single-transaction'; |
||
89 | } |
||
90 | |||
91 | if ($this->skipLockTables) { |
||
92 | $options['skipLockTables'] = '--skip-lock-tables'; |
||
93 | } |
||
94 | |||
95 | if ($this->quick) { |
||
96 | $options['quick'] = '--quick'; |
||
97 | } |
||
98 | if ($this->defaultCharacterSet) { |
||
99 | $options['defaultCharacterSet'] = '--default-character-set=' . $this->defaultCharacterSet; |
||
100 | } |
||
101 | if (count($this->tables) > 0) { |
||
102 | $options['tables'] = '--tables ' . implode(' ', $this->tables); |
||
103 | } |
||
104 | // Ignore Tables |
||
105 | $ignoreTables = []; |
||
106 | foreach ($this->ignoreTables as $tableName) { |
||
107 | $ignoreTables[] = "--ignore-table=" . $databaseArg . "." . $tableName; |
||
|
|||
108 | $options['ignoreTables'] = implode(' ', $ignoreTables); |
||
109 | } |
||
110 | return $options; |
||
111 | } |
||
193 |