Conditions | 14 |
Paths | 14 |
Total Lines | 45 |
Code Lines | 36 |
Lines | 36 |
Ratio | 80 % |
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 |
||
58 | protected function addDocblockTag($tag, DocBlock $docBlock) { |
||
59 | $tags = $docBlock->getTagsByName($tag); |
||
60 | switch ($tag) { |
||
61 | View Code Duplication | case 'return': |
|
62 | if (count($tags) === 0) continue; |
||
63 | /** @var Return_ $return */ |
||
64 | $return = $tags[0]; |
||
65 | $this->addMultiline(':returns: ' . $return->getType() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
66 | break; |
||
67 | View Code Duplication | case 'throws': |
|
68 | if (count($tags) === 0) continue; |
||
69 | /** @var Throws $return */ |
||
70 | $return = $tags[0]; |
||
71 | $this->addMultiline(':throws: ' . $return->getType() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
72 | break; |
||
73 | View Code Duplication | case 'since': |
|
74 | if (count($tags) === 0) continue; |
||
75 | /** @var Since $return */ |
||
76 | $return = $tags[0]; |
||
77 | $this->addMultiline(':since: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
78 | break; |
||
79 | View Code Duplication | case 'deprecated': |
|
80 | if (count($tags) === 0) continue; |
||
81 | /** @var Deprecated $return */ |
||
82 | $return = $tags[0]; |
||
83 | $this->addMultiline(':deprecated: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
84 | break; |
||
85 | View Code Duplication | case 'see': |
|
86 | if (count($tags) === 0) continue; |
||
87 | /** @var See $return */ |
||
88 | $return = $tags[0]; |
||
89 | $this->addMultiline(':see: ' . $return->getReference() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
90 | break; |
||
91 | View Code Duplication | case 'license': |
|
92 | if (count($tags) === 0) continue; |
||
93 | /** @var DocBlock\Tags\BaseTag $return */ |
||
94 | $return = $tags[0]; |
||
95 | $this->addMultiline(':license: ' . RstBuilder::escape($return->getDescription()), true); |
||
96 | break; |
||
97 | case 'param': |
||
98 | // param handling is done by subclasses since it is more that docbook parsing |
||
99 | break; |
||
100 | default: |
||
101 | //echo 'Tag handling not defined for: ' . $tag . PHP_EOL; |
||
102 | break; |
||
103 | } |
||
107 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.