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