Conditions | 14 |
Paths | 14 |
Total Lines | 19 |
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 |
||
110 | private function define($nodeValue):array |
||
111 | { |
||
112 | $v = substr($nodeValue, 1); |
||
113 | if (in_array($nodeValue[0], ['"', "'"])) { |
||
114 | $type = R::isProperlyQuoted($nodeValue) ? T::QUOTED : T::PARTIAL; |
||
115 | return [$type, $nodeValue]; |
||
116 | } |
||
117 | if (in_array($nodeValue[0], ['{', '['])) return $this->onObject($nodeValue); |
||
1 ignored issue
–
show
|
|||
118 | if (in_array($nodeValue[0], ['!', '&', '*'])) return $this->onNodeAction($nodeValue); |
||
1 ignored issue
–
show
|
|||
119 | switch ($nodeValue[0]) { |
||
120 | case '#': return [T::COMMENT, ltrim($v)]; |
||
1 ignored issue
–
show
|
|||
121 | case "-": return $this->onHyphen($nodeValue); |
||
1 ignored issue
–
show
|
|||
122 | case '%': return [T::DIRECTIVE, ltrim($v)]; |
||
1 ignored issue
–
show
|
|||
123 | case '?': return [T::SET_KEY, empty($v) ? null : new Node(ltrim($v), $this->line)]; |
||
1 ignored issue
–
show
|
|||
124 | case ':': return [T::SET_VALUE, empty($v) ? null : new Node(ltrim($v), $this->line)]; |
||
1 ignored issue
–
show
|
|||
125 | case '>': return [T::LITTERAL_FOLDED, null]; |
||
1 ignored issue
–
show
|
|||
126 | case '|': return [T::LITTERAL, null]; |
||
1 ignored issue
–
show
|
|||
127 | default: |
||
1 ignored issue
–
show
|
|||
128 | return [T::SCALAR, $nodeValue]; |
||
129 | } |
||
261 |