Conditions | 13 |
Paths | 4096 |
Total Lines | 51 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 | protected function prepareDumpCommand(string $credentialFile, string $destinationPath): string |
||
69 | { |
||
70 | $options = []; |
||
71 | |||
72 | if(count($this->tables) > 0) { |
||
73 | $options['tables'] = '--tables ' . implode(' ', $this->tables); |
||
74 | } |
||
75 | // Ignore Tables |
||
76 | $ignoreTables = []; |
||
77 | foreach ($this->ignoreTables as $tableName) { |
||
78 | $ignoreTables[] = "--ignore-table=" . $databaseArg . "." . $tableName; |
||
79 | $options['ignoreTables'] = implode(' ', $ignoreTables); |
||
80 | } |
||
81 | |||
82 | if($this->singleTransaction) { |
||
83 | $options['singleTransaction'] => '--single-transaction'; |
||
|
|||
84 | } |
||
85 | |||
86 | if($this->skipLockTable) { |
||
87 | $options['skipLockTable'] => '--skip-lock-tables'; |
||
88 | } |
||
89 | |||
90 | if($this->quick) { |
||
91 | $options['quick'] => '--quick'; |
||
92 | } |
||
93 | |||
94 | if(!$this->createTables) { |
||
95 | $options['createTables'] => '--no-create-info'; |
||
96 | } |
||
97 | if($this->skipComments) { |
||
98 | $options['skipComments'] => '--skip-comments'; |
||
99 | } |
||
100 | if($this->socket !== '') { |
||
101 | $options['socket'] => "--socket={$this->socket}"; |
||
102 | } |
||
103 | if($this->defaultCharacterSet) { |
||
104 | $options['defaultCharacterSet'] => '--default-character-set=' . $this->defaultCharacterSet; |
||
105 | } |
||
106 | if($this->authenticate) { |
||
107 | $options['authenticate'] => "--defaults-extra-file={$credentialFile}"; |
||
108 | } |
||
109 | // Dump command |
||
110 | $dumpCommand = sprintf( |
||
111 | '%smysqldump %s %s %s %s %s %s %s %s %s %s %s', |
||
112 | $this->dumpCommandPath, |
||
113 | $authenticate, |
||
114 | $this->dbName, |
||
115 | $options['socket'], |
||
116 | $options['skipComments'], |
||
117 | $options['createTables'], |
||
118 | $options['singleTransaction'], |
||
119 | $options['skipLockTable'], |
||
201 |