Conditions | 10 |
Paths | 12 |
Total Lines | 31 |
Code Lines | 19 |
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) { |
||
15 | continue; |
||
16 | } |
||
17 | |||
18 | $oldChildValue = $this->getChildValue($result, $property); |
||
19 | $isChildValueArray = is_array($oldChildValue); |
||
20 | if (null !== $oldChildValue && !$isChildValueArray) { |
||
21 | continue; |
||
22 | } |
||
23 | |||
24 | $childValue = $parser->setLines($this->getLines())->parse(); |
||
25 | if (null === $childValue) { |
||
26 | continue; |
||
27 | } |
||
28 | |||
29 | $isChildValueArray ? $this->addChildValue($result, $property, $childValue) : $this->setChildValue($result, $property, $childValue); |
||
30 | $parsedSequence = $parser->getSequence(); |
||
31 | |||
32 | break; |
||
33 | } |
||
34 | } while ($this->shouldParseNextLine($result, $parsedSequence) && $this->moveToNextLine()); |
||
35 | |||
36 | return $parsedSequence > -1 ? $result : null; |
||
37 | } |
||
38 | |||
79 |