| 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 | // Database |
||
| 71 | $databaseArg = $this->dbName; |
||
| 72 | // Include tables |
||
| 73 | $includeTables = (count($this->tables) > 0) ? implode(' ', $this->tables) : ""; |
||
| 74 | $includeTablesArg = !empty($includeTables) ? '--tables ' . $includeTables : ''; |
||
| 75 | // Ignore Tables |
||
| 76 | $ignoreTablesArgs = []; |
||
| 77 | foreach ($this->ignoreTables as $tableName) { |
||
| 78 | $ignoreTablesArgs[] = "--ignore-table=" . $databaseArg . "." . $tableName; |
||
| 79 | } |
||
| 80 | $ignoreTablesArg = (count($ignoreTablesArgs) > 0) ? implode(' ', $ignoreTablesArgs) : ''; |
||
| 81 | // Single Transaction |
||
| 82 | $singleTransaction = ($this->singleTransaction) ? "--single-transaction" : ""; |
||
| 83 | // Skip Lock Table |
||
| 84 | $skipLockTable = ($this->skipLockTables) ? "--skip-lock-tables" : ""; |
||
| 85 | // Quick |
||
| 86 | $quick = ($this->quick) ? "--quick" : ""; |
||
| 87 | // Create Tables |
||
| 88 | $createTables = (!$this->createTables) ? '--no-create-info' : ''; |
||
| 89 | // Skip Comments |
||
| 90 | $skipComments = ($this->skipComments) ? '--skip-comments' : ''; |
||
| 91 | // Socket |
||
| 92 | $socket = ($this->socket !== '') ? "--socket={$this->socket}" : ''; |
||
| 93 | // Default charecter set |
||
| 94 | $defaultCharacterSet = ($this->defaultCharacterSet !== '') ? '--default-character-set=' . $this->defaultCharacterSet : ''; |
||
| 95 | // Authentication File |
||
| 96 | $authenticate = "--defaults-extra-file=" . $credentialFile; |
||
| 97 | // Dump command |
||
| 98 | $dumpCommand = sprintf( |
||
| 99 | '%smysqldump %s %s %s %s %s %s %s %s %s %s %s', |
||
| 100 | $this->dumpCommandPath, |
||
| 101 | $authenticate, |
||
| 102 | $databaseArg, |
||
| 103 | $socket, |
||
| 104 | $skipComments, |
||
| 105 | $createTables, |
||
| 106 | $singleTransaction, |
||
| 107 | $skipLockTable, |
||
| 108 | $quick, |
||
| 109 | $defaultCharacterSet, |
||
| 110 | $includeTablesArg, |
||
| 111 | $ignoreTablesArg |
||
| 112 | ); |
||
| 113 | // Add compressor if compress is enable |
||
| 114 | if ($this->isCompress) { |
||
| 115 | return "{$dumpCommand} | {$this->compressBinaryPath}{$this->compressCommand} > {$destinationPath}{$this->compressExtension}"; |
||
| 116 | } |
||
| 117 | |||
| 118 | return "{$dumpCommand} > {$destinationPath}"; |
||
| 119 | } |
||
| 189 |