| Conditions | 11 |
| Paths | 1024 |
| Total Lines | 63 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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->skipLockTables) { |
||
| 87 | $options['skipLockTables'] = '--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 | |||
| 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 | $options['authenticate'] ?? "", |
||
| 114 | $this->dbName, |
||
| 115 | $options['socket'] ?? "", |
||
| 116 | $options['skipComments'] ?? "", |
||
| 117 | $options['createTables'] ?? "", |
||
| 118 | $options['singleTransaction'] ?? "", |
||
| 119 | $options['skipLockTables'] ?? "", |
||
| 120 | $options['quick'] ?? "", |
||
| 121 | $options['defaultCharacterSet'] ?? "", |
||
| 122 | $options['tables'] ?? "", |
||
| 123 | $options['ignoreTables'] ?? "" |
||
| 124 | ); |
||
| 125 | // Add compressor if compress is enable |
||
| 126 | if ($this->isCompress) { |
||
| 127 | return "{$dumpCommand} | {$this->compressBinaryPath}{$this->compressCommand} > {$destinationPath}{$this->compressExtension}"; |
||
| 128 | } |
||
| 129 | |||
| 130 | return "{$dumpCommand} > {$destinationPath}"; |
||
| 131 | } |
||
| 201 |