| Conditions | 11 |
| Paths | 8 |
| Total Lines | 30 |
| Code Lines | 18 |
| 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 | $lineInfo = $this->getStream()->read(); |
||
| 14 | if (null === $lineInfo) { |
||
| 15 | continue; |
||
| 16 | } |
||
| 17 | |||
| 18 | foreach ($this->getCores() as $property => $parser) { |
||
| 19 | if ($parser->getSequence() < $parsedSequence || null !== $result->$property && !is_array($result->$property)) { |
||
| 20 | continue; |
||
| 21 | } |
||
| 22 | |||
| 23 | $childResult = $parser->setStream($this->getStream())->parse(); |
||
| 24 | if (null === $childResult) { |
||
| 25 | continue; |
||
| 26 | } |
||
| 27 | |||
| 28 | is_array($result->$property) ? $result->$property[] = $childResult : $result->$property = $childResult; |
||
| 29 | $parsedSequence = $parser->getSequence(); |
||
| 30 | |||
| 31 | break; |
||
| 32 | } |
||
| 33 | } while ($this->shouldParseNextLine($result, $parsedSequence) && $this->moveToNextLine()); |
||
| 34 | |||
| 35 | return $parsedSequence > -1 ? $result : null; |
||
| 36 | } |
||
| 37 | |||
| 65 |