| Conditions | 14 |
| Paths | 14 |
| Total Lines | 46 |
| Code Lines | 38 |
| Lines | 30 |
| Ratio | 65.22 % |
| 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 |
||
| 88 | protected function addDocblockTag($tag, DocBlock $docBlock) { |
||
| 89 | $indent = 0; |
||
| 90 | $tags = $docBlock->getTagsByName($tag); |
||
| 91 | switch ($tag) { |
||
| 92 | View Code Duplication | case 'return': |
|
| 93 | if (sizeof($tags) === 0) continue; |
||
| 94 | /** @var Return_ $return */ |
||
| 95 | $return = $tags[0]; |
||
| 96 | $this->addIndentMultiline($indent, ':returns: ' . $return->getType() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
| 97 | break; |
||
| 98 | View Code Duplication | case 'throws': |
|
| 99 | if (sizeof($tags) === 0) continue; |
||
| 100 | /** @var Throws $return */ |
||
| 101 | $return = $tags[0]; |
||
| 102 | $this->addIndentMultiline($indent, ':throws: ' . $return->getType() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
| 103 | break; |
||
| 104 | View Code Duplication | case 'since': |
|
| 105 | if (sizeof($tags) === 0) continue; |
||
| 106 | /** @var Since $return */ |
||
| 107 | $return = $tags[0]; |
||
| 108 | $this->addIndentMultiline($indent, ':since: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
| 109 | break; |
||
| 110 | View Code Duplication | case 'deprecated': |
|
| 111 | if (sizeof($tags) === 0) continue; |
||
| 112 | /** @var Deprecated $return */ |
||
| 113 | $return = $tags[0]; |
||
| 114 | $this->addIndentMultiline($indent, ':deprecated: ' . $return->getVersion() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
| 115 | break; |
||
| 116 | View Code Duplication | case 'see': |
|
| 117 | if (sizeof($tags) === 0) continue; |
||
| 118 | /** @var See $return */ |
||
| 119 | $return = $tags[0]; |
||
| 120 | $this->addIndentMultiline($indent, ':see: ' . $return->getReference() . ' ' . RstBuilder::escape($return->getDescription()), true); |
||
| 121 | break; |
||
| 122 | case 'license': |
||
| 123 | if (sizeof($tags) === 0) continue; |
||
| 124 | /** @var DocBlock\Tags\BaseTag $return */ |
||
| 125 | $return = $tags[0]; |
||
| 126 | $this->addIndentMultiline($indent, ':license: ' . RstBuilder::escape($return->getDescription()), true); |
||
| 127 | break; |
||
| 128 | case 'param': |
||
| 129 | // param handling is done by subclasses since it is more that docbook parsing |
||
| 130 | break; |
||
| 131 | default: |
||
| 132 | echo 'Tag handling not defined for: ' . $tag . PHP_EOL; |
||
| 133 | break; |
||
| 134 | } |
||
| 139 | } |
This check marks private properties in classes that are never used. Those properties can be removed.