ProcessorMapper::map()   C
last analyzed

Complexity

Conditions 12
Paths 12

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 26
cts 26
cp 1
rs 6.9666
c 0
b 0
f 0
cc 12
nc 12
nop 1
crap 12

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
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11MonoLog\Processor;
6
7
use WShafer\PSR11MonoLog\MapperInterface;
8
9
/**
10
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
11
 */
12
class ProcessorMapper implements MapperInterface
13
{
14
    /**
15
     * @param string $type
16
     * @return null|string
17
     *
18
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
19
     */
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