| Conditions | 10 |
| Paths | 10 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 7 | public function parse() |
||
| 8 | { |
||
| 9 | $parsedSequence = -1; |
||
| 10 | $result = $this->initResult(); |
||
| 11 | |||
| 12 | do { |
||
| 13 | foreach ($this->getChildren() as $property => $parser) { |
||
| 14 | if ($parser->getSequence() < $parsedSequence || null !== $result->$property && !is_array($result->$property)) { |
||
| 15 | continue; |
||
| 16 | } |
||
| 17 | |||
| 18 | $childResult = $parser->setLines($this->getLines())->parse(); |
||
| 19 | if (null === $childResult) { |
||
| 20 | continue; |
||
| 21 | } |
||
| 22 | |||
| 23 | is_array($result->$property) ? $result->$property[] = $childResult : $result->$property = $childResult; |
||
| 24 | $parsedSequence = $parser->getSequence(); |
||
| 25 | |||
| 26 | break; |
||
| 27 | } |
||
| 28 | } while ($this->shouldParseNextLine($result, $parsedSequence) && $this->moveToNextLine()); |
||
| 29 | |||
| 30 | return $parsedSequence > -1 ? $result : null; |
||
| 31 | } |
||
| 32 | |||
| 67 |