| Conditions | 10 |
| Paths | 10 |
| Total Lines | 26 |
| Code Lines | 20 |
| 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 |
||
| 89 | private function loadAnnotations(array $annotations) |
||
| 90 | { |
||
| 91 | $definition = []; |
||
| 92 | |||
| 93 | foreach ($annotations as $annotation) { |
||
| 94 | if ($annotation instanceof Alias) { |
||
| 95 | $definition['alias'] = $annotation->getAlias(); |
||
| 96 | } elseif ($annotation instanceof Type) { |
||
| 97 | $definition['type'] = $annotation->getType(); |
||
| 98 | } elseif ($annotation instanceof Expose) { |
||
| 99 | $definition['expose'] = true; |
||
| 100 | } elseif ($annotation instanceof Exclude) { |
||
| 101 | $definition['exclude'] = true; |
||
| 102 | } elseif ($annotation instanceof Since) { |
||
| 103 | $definition['since'] = $annotation->getVersion(); |
||
| 104 | } elseif ($annotation instanceof Until) { |
||
| 105 | $definition['until'] = $annotation->getVersion(); |
||
| 106 | } elseif ($annotation instanceof MaxDepth) { |
||
| 107 | $definition['max_depth'] = $annotation->getMaxDepth(); |
||
| 108 | } elseif ($annotation instanceof Groups) { |
||
| 109 | $definition['groups'] = $annotation->getGroups(); |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | return $definition; |
||
| 114 | } |
||
| 115 | } |
||
| 116 |