| Conditions | 11 |
| Paths | 1024 |
| Total Lines | 44 |
| Code Lines | 31 |
| 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 |
||
| 49 | protected function prepareDumpCommand(string $destinationPath): string |
||
| 50 | { |
||
| 51 | $databaseArg = !empty($this->dbName) ? "--db " . escapeshellarg($this->dbName) : ""; |
||
| 52 | $username = !empty($this->username) ? "--username " . escapeshellarg($this->username) : ""; |
||
| 53 | $password = !empty($this->password) ? "--password " . escapeshellarg($this->password) : ""; |
||
| 54 | $host = !empty($this->host) ? "--host " . escapeshellarg($this->host) : ""; |
||
| 55 | $port = !empty($this->port) ? "--port " . escapeshellarg($this->port) : ""; |
||
| 56 | $collection = !empty($this->collection) ? "--collection " . escapeshellarg($this->collection) : ""; |
||
| 57 | $authenticationDatabase = !empty($this->authenticationDatabase) ? "--authenticationDatabase " . escapeshellarg($this->authenticationDatabase) : ""; |
||
| 58 | $archive = ""; |
||
| 59 | |||
| 60 | if ($this->isCompress) { |
||
| 61 | |||
| 62 | $archive = "--archive --gzip"; |
||
| 63 | } |
||
| 64 | |||
| 65 | $dumpCommand = sprintf( |
||
| 66 | '%smongodump %s %s %s %s %s %s %s %s', |
||
| 67 | $this->dumpCommandPath, |
||
| 68 | $archive, |
||
| 69 | $databaseArg, |
||
| 70 | $username, |
||
| 71 | $password, |
||
| 72 | $host, |
||
| 73 | $port, |
||
| 74 | $collection, |
||
| 75 | $authenticationDatabase |
||
| 76 | ); |
||
| 77 | |||
| 78 | if ($this->uri) { |
||
| 79 | $dumpCommand = sprintf( |
||
| 80 | '%smongodump %s --uri %s %s', |
||
| 81 | $this->dumpCommandPath, |
||
| 82 | $archive, |
||
| 83 | $this->uri, |
||
| 84 | $collection |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 88 | if ($this->isCompress) { |
||
| 89 | return "{$dumpCommand} > {$destinationPath}{$this->compressExtension}"; |
||
| 90 | } |
||
| 91 | |||
| 92 | return "{$dumpCommand} --out {$destinationPath}"; |
||
| 93 | } |
||
| 135 |