Conditions | 11 |
Paths | 11 |
Total Lines | 29 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 23 |
CRAP Score | 11 |
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 |
||
19 | 11 | public function map(string $type) |
|
20 | { |
||
21 | 11 | $type = strtolower($type); |
|
22 | |||
23 | switch ($type) { |
||
24 | 11 | case 'psrlogmessage': |
|
25 | 1 | return PsrLogMessageProcessorFactory::class; |
|
26 | 10 | case 'introspection': |
|
27 | 1 | return IntrospectionProcessorFactory::class; |
|
28 | 9 | case 'web': |
|
29 | 1 | return WebProcessorFactory::class; |
|
30 | 8 | case 'memoryusage': |
|
31 | 1 | return MemoryUsageProcessorFactory::class; |
|
32 | 7 | case 'memorypeak': |
|
33 | 1 | return MemoryPeakUsageProcessorFactory::class; |
|
34 | 6 | case 'processid': |
|
35 | 1 | return ProcessIdProcessorFactory::class; |
|
36 | 5 | case 'uid': |
|
37 | 1 | return UidProcessorFactory::class; |
|
38 | 4 | case 'git': |
|
39 | 1 | return GitProcessorFactory::class; |
|
40 | 3 | case 'mercurial': |
|
41 | 1 | return MercurialProcessorFactory::class; |
|
42 | 2 | case 'tags': |
|
43 | 1 | return TagProcessorFactory::class; |
|
44 | } |
||
45 | |||
46 | 1 | return null; |
|
47 | } |
||
48 | } |
||
49 |