| Conditions | 10 |
| Paths | 7 |
| Total Lines | 28 |
| Code Lines | 14 |
| 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 |
||
| 132 | private function className($name, array $config) |
||
| 133 | { |
||
| 134 | if (isset($config['class']) && isset($config['factory'])) { |
||
| 135 | throw InvalidConfigException::fromNameWhenClassAndFactorySpecified($name); |
||
| 136 | } |
||
| 137 | |||
| 138 | if (isset($config['class']) && isset($config['service'])) { |
||
| 139 | throw InvalidConfigException::fromNameWhenClassAndServiceSpecified($name); |
||
| 140 | } |
||
| 141 | |||
| 142 | if (isset($config['factory']) && isset($config['service'])) { |
||
| 143 | throw InvalidConfigException::fromNameWhenFactoryAndServiceSpecified($name); |
||
| 144 | } |
||
| 145 | |||
| 146 | if (isset($config['service'])) { |
||
| 147 | return $config['service']; |
||
| 148 | } |
||
| 149 | |||
| 150 | if (isset($config['class'])) { |
||
| 151 | return $config['class']; |
||
| 152 | } |
||
| 153 | |||
| 154 | if (isset($config['factory'])) { |
||
| 155 | return $config['factory']; |
||
| 156 | } |
||
| 157 | |||
| 158 | return $name; |
||
| 159 | } |
||
| 160 | } |
||
| 161 |