Completed
Push — master ( 67f16c...309264 )
by Westin
01:42
created

ProcessorMapper::map()   C

Complexity

Conditions 11
Paths 11

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 11

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 23
cts 23
cp 1
rs 5.2653
c 0
b 0
f 0
cc 11
eloc 24
nc 11
nop 1
crap 11

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 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