| Conditions | 4 |
| Paths | 4 |
| Total Lines | 61 |
| Code Lines | 31 |
| Lines | 61 |
| Ratio | 100 % |
| 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 |
||
| 51 | if (!$this->isValid()) { |
||
| 52 | throw new \InvalidArgumentException(sprintf( |
||
| 53 | "Local location validation failed for Location with directory '%s'", |
||
| 54 | $this->directory |
||
| 55 | )); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var CommandChain $pipeChainedCommands |
||
| 60 | */ |
||
| 61 | $pipeChainedCommands = $this->buildPipeChainedCommands(); |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var CommandChain $sequenceChainedCommands |
||
| 65 | */ |
||
| 66 | $sequenceChainedCommands = $this->buildSequenceChainedCommands(); |
||
| 67 | $sequenceChainedCommands->addCommand($pipeChainedCommands); |
||
| 68 | |||
| 69 | return $sequenceChainedCommands; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritdoc} |
||
| 74 | */ |
||
| 75 | public function getName() |
||
| 76 | { |
||
| 77 | if (empty($this->name)) { |
||
| 78 | $this->name = $this->getDirectory(); |
||
| 79 | } |
||
| 80 | |||
| 81 | return $this->name; |
||
| 82 | } |
||
| 83 | } |
||
| 84 |