Conditions | 10 |
Paths | 15 |
Total Lines | 25 |
Code Lines | 16 |
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 |
||
73 | public function isAwaitingChild(Node $node):bool |
||
74 | { |
||
75 | if (is_null($this->value) || $node instanceof NodeComment) { |
||
76 | return true; |
||
77 | } |
||
78 | $current = $this->value instanceof Node ? $this->value : $this->value->current(); |
||
79 | if ($current instanceof NodeComment) { |
||
80 | return true; |
||
81 | } |
||
82 | if($current instanceof NodeScalar) { |
||
83 | return isOneOf($node, ['NodeScalar', 'NodeBlank']); |
||
84 | } |
||
85 | if ($current instanceof NodeItem) { |
||
86 | return $node instanceof NodeItem; |
||
87 | } |
||
88 | if ($current instanceof NodeKey) { |
||
89 | return $node instanceof NodeKey; |
||
90 | } |
||
91 | if ($current instanceof NodeLiterals) { |
||
92 | return $node->indent > $this->indent; |
||
93 | } |
||
94 | if ($current instanceof NodeAnchor) { |
||
95 | return $current->isAwaitingChild($node); |
||
96 | } |
||
97 | return false; |
||
98 | } |
||
122 | } |