Conditions | 10 |
Paths | 14 |
Total Lines | 28 |
Code Lines | 22 |
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 |
||
29 | public static function buildContent(NodeRoot $root, int $_debug) |
||
30 | { |
||
31 | self::$_debug = $_debug; |
||
32 | if ($_debug === 2) { |
||
33 | print_r($root); |
||
34 | return; |
||
35 | } |
||
36 | $documents = []; |
||
37 | $buffer = new NodeList(); |
||
38 | try { |
||
39 | foreach ($root->value as $child) { |
||
40 | if ($child instanceof NodeDocEnd && $child !== $root->value->top()) { |
||
|
|||
41 | $buffer->push($child); |
||
42 | $documents[] = self::buildDocument($buffer, count($documents)); |
||
43 | $buffer = new NodeList(); |
||
44 | continue; |
||
45 | } elseif ($child instanceof NodeDocStart && $buffer->count() > 0 && $buffer->hasContent()) { |
||
46 | $documents[] = self::buildDocument($buffer, count($documents)); |
||
47 | $buffer = new NodeList($child); |
||
48 | continue; |
||
49 | } |
||
50 | $buffer->push($child); |
||
51 | } |
||
52 | $documents[] = self::buildDocument($buffer, count($documents)); |
||
53 | } catch (\Exception|\Error|\ParseError $e) { |
||
54 | throw new \Exception($e->getMessage(), 1, $e); |
||
55 | } |
||
56 | return count($documents) === 1 ? $documents[0] : $documents; |
||
57 | } |
||
123 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.