| Conditions | 4 |
| Paths | 4 |
| Total Lines | 56 |
| Code Lines | 30 |
| Lines | 56 |
| Ratio | 100 % |
| Changes | 5 | ||
| 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 |
||
| 143 | * @var RemoteConnection $remoteConnection |
||
| 144 | */ |
||
| 145 | $remoteConnection = $this->getRemoteConnection(); |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @var CommandChain $sshCommandChain |
||
| 149 | */ |
||
| 150 | $sshCommandChain = $this->buildSshCommandChain($remoteConnection); |
||
| 151 | |||
| 152 | return $sshCommandChain; |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Auxiliary function. |
||
| 157 | * |
||
| 158 | * @param RemoteConnection $remoteConnection |
||
| 159 | * @return ShellCommand |
||
| 160 | */ |
||
| 161 | protected function buildSshCommandChain(RemoteConnection $remoteConnection) |
||
| 162 | { |
||
| 163 | /** |
||
| 164 | * @var CommandChain $commandChain |
||
| 165 | */ |
||
| 166 | $commandChain = $this->buildRemoteCommandChain(); |
||
| 167 | |||
| 168 | $sshCommand = $remoteConnection->getCommand(true); |
||
| 169 | $sshCommand->addParameter(sprintf( |
||
| 170 | '"%s"', |
||
| 171 | $commandChain->getCommand() |
||
| 172 | )); |
||
| 173 | |||
| 174 | return $sshCommand; |
||
| 175 | } |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Auxiliary function. |
||
| 179 | * @return CommandChain |
||
| 180 | */ |
||
| 181 | protected function buildRemoteCommandChain() |
||
| 182 | { |
||
| 183 | /** |
||
| 184 | * @var CommandChain $pipeChainedCommands |
||
| 185 | */ |
||
| 186 | $pipeChainedCommands = $this->buildPipeChainedCommands(); |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @var CommandChain $sequenceChainedCommands |
||
| 190 | */ |
||
| 191 | $sequenceChainedCommands = $this->buildSequenceChainedCommands(); |
||
| 192 | $sequenceChainedCommands->addCommand($pipeChainedCommands); |
||
| 193 | |||
| 194 | return $sequenceChainedCommands; |
||
| 195 | } |
||
| 196 | |||
| 197 | /** |
||
| 198 | * {@inheritdoc} |
||
| 199 | */ |
||
| 221 |