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