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