Completed
Push — master ( bada4b...c7ceb7 )
by Westin
01:42
created

ProcessorMapper::map()   D

Complexity

Conditions 10
Paths 10

Size

Total Lines 27
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 10.0107

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 20
cts 21
cp 0.9524
rs 4.8196
c 0
b 0
f 0
cc 10
eloc 22
nc 10
nop 1
crap 10.0107

How to fix   Complexity   

Long Method

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:

1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11MonoLog\Processor;
5
6
use WShafer\PSR11MonoLog\MapperInterface;
7
8
/**
9
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
10
 */
11
class ProcessorMapper implements MapperInterface
12
{
13
    /**
14
     * @param string $type
15
     * @return null|string
16
     *
17
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
18
     */
19 9
    public function map(string $type)
20
    {
21 9
        $type = strtolower($type);
22
23
        switch ($type) {
24 9
            case 'psrlogmessage':
25 1
                return PsrLogMessageProcessorFactory::class;
26 8
            case 'introspection':
27 1
                return IntrospectionProcessorFactory::class;
28 7
            case 'web':
29 1
                return WebProcessorFactory::class;
30 6
            case 'memoryusage':
31 1
                return MemoryUsageProcessorFactory::class;
32 5
            case 'memorypeak':
33 1
                return MemoryPeakUsageProcessorFactory::class;
34 4
            case 'processid':
35 1
                return ProcessIdProcessorFactory::class;
36 3
            case 'uid':
37 1
                return UidProcessorFactory::class;
38 2
            case 'git':
39 1
                return GitProcessorFactory::class;
40 1
            case 'mercurial':
41
                return MercurialProcessorFactory::class;
42
        }
43
44 1
        return null;
45
    }
46
}
47