Conditions | 14 |
Paths | 14 |
Total Lines | 33 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 29 |
CRAP Score | 14 |
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 |
||
17 | 14 | public function map(string $type): ?FactoryInterface |
|
18 | { |
||
19 | 14 | $type = strtolower($type); |
|
20 | |||
21 | 14 | switch ($type) { |
|
22 | 14 | case 'apc': |
|
23 | 1 | return new ApcAdapterFactory(); |
|
24 | 13 | case 'apcu': |
|
25 | 1 | return new ApcuAdapterFactory(); |
|
26 | 12 | case 'array': |
|
27 | 1 | return new ArrayAdapterFactory(); |
|
28 | 11 | case 'chain': |
|
29 | 1 | return new ChainCacheAdapterFactory(); |
|
30 | 10 | case 'doctrine': |
|
31 | 1 | return new DoctrineCacheAdapterFactory(); |
|
32 | 9 | case 'filesystem': |
|
33 | 1 | return new FileSystemAdapterFactory(); |
|
34 | 8 | case 'illuminate': |
|
35 | 1 | return new IlluminateAdapterFactory(); |
|
36 | 7 | case 'memcached': |
|
37 | 1 | return new MemcachedAdapterFactory(); |
|
38 | 6 | case 'mongodb': |
|
39 | 5 | case 'mongo': |
|
40 | 2 | return new MongoAdapterFactory(); |
|
41 | 4 | case 'predis': |
|
42 | 1 | return new PredisAdapterFactory(); |
|
43 | 3 | case 'redis': |
|
44 | 1 | return new RedisAdapterFactory(); |
|
45 | 2 | case 'void': |
|
46 | 1 | return new VoidAdapterFactory(); |
|
47 | } |
||
48 | |||
49 | 1 | return null; |
|
50 | } |
||
52 |