Conditions | 11 |
Paths | 1024 |
Total Lines | 52 |
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 | $options = [ |
||
52 | 'archive' => '', |
||
53 | 'database' => '', |
||
54 | 'username' => '', |
||
55 | 'password' => '', |
||
56 | 'host' => '', |
||
57 | 'port' => '', |
||
58 | 'collection' => '', |
||
59 | 'authenticationDatabase' => '', |
||
60 | ]; |
||
61 | // Database |
||
62 | if(!empty($this->dbName)) { |
||
63 | $options['database'] = "--db {$this->dbName}"; |
||
64 | } |
||
65 | // Username |
||
66 | if(!empty($this->username)) { |
||
67 | $options['username'] = "--username {$this->username}"; |
||
68 | } |
||
69 | //Password |
||
70 | if(!empty($this->password)) { |
||
71 | $options['password'] = "--password {$this->password}"; |
||
72 | } |
||
73 | // Host |
||
74 | if(!empty($this->host)) { |
||
75 | $options['host'] "--host {$this->host}"; |
||
|
|||
76 | } |
||
77 | // Port |
||
78 | if(!empty($this->port)) { |
||
79 | $options['port'] = "--port {$this->port}"; |
||
80 | } |
||
81 | // Collection |
||
82 | if(!empty($this->collection)) { |
||
83 | $options['collection'] = "--collection {$this->collection}"; |
||
84 | } |
||
85 | // Authentication Database |
||
86 | if(!empty($this->authenticationDatabase)) { |
||
87 | $options[] = "--authenticationDatabase {$this->authenticationDatabase}"; |
||
88 | } |
||
89 | // Archive |
||
90 | if ($this->isCompress) { |
||
91 | $options['archive'] = "--archive --gzip"; |
||
92 | } |
||
93 | // Dump Command |
||
94 | $dumpCommand = sprintf( |
||
95 | '%smongodump %s %s %s %s %s %s %s %s', |
||
96 | $this->dumpCommandPath, |
||
97 | $archive, |
||
98 | $databaseArg, |
||
99 | $username, |
||
100 | $password, |
||
101 | $host, |
||
167 |