AdapterMapper   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
c 1
b 0
f 0
dl 0
loc 40
ccs 29
cts 29
cp 1
rs 10
wmc 14

1 Method

Rating   Name   Duplication   Size   Complexity  
C map() 0 33 14
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11PhpCache\Adapter;
6
7
/**
8
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
9
 */
10
class AdapterMapper
11
{
12
    /**
13
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
14
     * @param string $type
15
     * @return \WShafer\PSR11PhpCache\Adapter\FactoryInterface|null
16
     */
17 14
    public function map(string $type): ?FactoryInterface
18
    {
19 14
        $type = strtolower($type);
20
21 14
        switch ($type) {
22 14
            case 'apc':
23 1
                return new ApcAdapterFactory();
24 13
            case 'apcu':
25 1
                return new ApcuAdapterFactory();
26 12
            case 'array':
27 1
                return new ArrayAdapterFactory();
28 11
            case 'chain':
29 1
                return new ChainCacheAdapterFactory();
30 10
            case 'doctrine':
31 1
                return new DoctrineCacheAdapterFactory();
32 9
            case 'filesystem':
33 1
                return new FileSystemAdapterFactory();
34 8
            case 'illuminate':
35 1
                return new IlluminateAdapterFactory();
36 7
            case 'memcached':
37 1
                return new MemcachedAdapterFactory();
38 6
            case 'mongodb':
39 5
            case 'mongo':
40 2
                return new MongoAdapterFactory();
41 4
            case 'predis':
42 1
                return new PredisAdapterFactory();
43 3
            case 'redis':
44 1
                return new RedisAdapterFactory();
45 2
            case 'void':
46 1
                return new VoidAdapterFactory();
47
        }
48
49 1
        return null;
50
    }
51
}
52