Conditions | 15 |
Paths | 15 |
Total Lines | 46 |
Code Lines | 36 |
Lines | 37 |
Ratio | 80.43 % |
Changes | 1 | ||
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 |
||
133 | protected function addDocblockTag($tagName, DocBlock $docBlock) { |
||
134 | $tags = $docBlock->getTagsByName($tagName); |
||
135 | switch ($tagName) { |
||
136 | View Code Duplication | case 'return': |
|
137 | if (count($tags) === 0) continue; |
||
138 | /** @var Return_ $return */ |
||
139 | $return = $tags[0]; |
||
140 | $this->addMultiline(':returns: ' . $return->getType() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
141 | break; |
||
142 | View Code Duplication | case 'throws': |
|
143 | if (count($tags) === 0) continue; |
||
144 | /** @var Throws $tag */ |
||
145 | foreach ($tags as $tag) { |
||
146 | $this->addMultiline(':throws: ' . $tag->getType() . ' ' . RstBuilder::escape($tag->getDescription()), true); |
||
147 | } |
||
148 | break; |
||
149 | View Code Duplication | case 'since': |
|
150 | if (count($tags) === 0) continue; |
||
151 | /** @var Since $return */ |
||
152 | $return = $tags[0]; |
||
153 | $this->addMultiline(':since: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
154 | break; |
||
155 | View Code Duplication | case 'deprecated': |
|
156 | if (count($tags) === 0) continue; |
||
157 | /** @var Deprecated $return */ |
||
158 | $return = $tags[0]; |
||
159 | $this->addMultiline(':deprecated: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
160 | break; |
||
161 | View Code Duplication | case 'see': |
|
162 | if (count($tags) === 0) continue; |
||
163 | /** @var See $return */ |
||
164 | $return = $tags[0]; |
||
165 | $this->addMultiline(':see: ' . $return->getReference() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
166 | break; |
||
167 | View Code Duplication | case 'license': |
|
168 | if (count($tags) === 0) continue; |
||
169 | /** @var DocBlock\Tags\BaseTag $return */ |
||
170 | $return = $tags[0]; |
||
171 | $this->addMultiline(':license: ' . RstBuilder::escape($return->getDescription()), true); |
||
172 | break; |
||
173 | case 'param': |
||
174 | // param handling is done by subclasses since it is more that docbook parsing |
||
175 | break; |
||
176 | default: |
||
177 | //echo 'Tag handling not defined for: ' . $tag . PHP_EOL; |
||
178 | break; |
||
179 | } |
||
193 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.