| Conditions | 11 |
| Paths | 8 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 37 | public function find(AbstractNode $node) |
||
| 38 | { |
||
| 39 | if (!$node->id() && $node instanceof InnerNode) { |
||
| 40 | return $this->find($node->firstChild()); |
||
| 41 | } |
||
| 42 | |||
| 43 | if ($node->id() == $this->id) { |
||
| 44 | return $node; |
||
| 45 | } |
||
| 46 | |||
| 47 | if ($node->hasNextSibling()) { |
||
| 48 | $nextSibling = $node->nextSibling(); |
||
| 49 | if ($nextSibling->id() == $this->id) { |
||
| 50 | return $nextSibling; |
||
| 51 | } |
||
| 52 | if ($nextSibling->id() > $this->id && $node instanceof InnerNode) { |
||
| 53 | return $this->find($node->firstChild()); |
||
| 54 | } |
||
| 55 | if ($nextSibling->id() < $this->id) { |
||
| 56 | return $this->find($nextSibling); |
||
| 57 | } |
||
| 58 | } elseif (!$node->isTextNode() && $node instanceof InnerNode) { |
||
| 59 | return $this->find($node->firstChild()); |
||
| 60 | } |
||
| 61 | |||
| 62 | return false; |
||
| 63 | } |
||
| 65 |