| Conditions | 10 | 
| Paths | 12 | 
| Total Lines | 34 | 
| Code Lines | 21 | 
| 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  | 
            ||
| 12 | public function parse()  | 
            ||
| 13 |     { | 
            ||
| 14 | $parsedSequence = -1;  | 
            ||
| 15 | $result = $this->builder->setResult($this->initResult());  | 
            ||
| 16 | |||
| 17 | $ret = null;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 18 |         do { | 
            ||
| 19 |             foreach ($this->getChildren() as $property => $parser) { | 
            ||
| 20 |                 if ($parser->getSequence() < $parsedSequence) { | 
            ||
| 21 | continue;  | 
            ||
| 22 | }  | 
            ||
| 23 | |||
| 24 | $oldChildValue = $this->builder->getValue($property);  | 
            ||
| 25 | $isChildValueArray = is_array($oldChildValue);  | 
            ||
| 26 |                 if (null !== $oldChildValue && !$isChildValueArray) { | 
            ||
| 27 | continue;  | 
            ||
| 28 | }  | 
            ||
| 29 | |||
| 30 | $childValue = $parser->setLines($this->getLines())->parse();  | 
            ||
| 31 |                 if (null === $childValue) { | 
            ||
| 32 | continue;  | 
            ||
| 33 | }  | 
            ||
| 34 | |||
| 35 | $isChildValueArray ? $this->builder->addValue($property, $childValue) : $this->builder->setValue($property, $childValue);  | 
            ||
| 36 | $parsedSequence = $parser->getSequence();  | 
            ||
| 37 | |||
| 38 | break;  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 | $ret = $parsedSequence > -1 ? $result : null;  | 
            ||
| 42 | } while ($this->shouldParseNextLine($ret) && $this->moveToNextLine());  | 
            ||
| 43 | |||
| 44 | return $ret;  | 
            ||
| 45 | }  | 
            ||
| 46 | |||
| 81 | 
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.