CacheFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
wmc 2
lcom 0
cbo 4
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 15 2
1
<?php
2
namespace mxdiModule\Factory\Cache;
3
4
use Zend\Cache\Storage\Adapter\AbstractAdapter;
5
use Zend\Cache\Storage\Plugin\Serializer;
6
use Zend\Cache\Storage\StorageInterface;
7
use Zend\Cache\StorageFactory;
8
use Zend\ServiceManager\FactoryInterface;
9
use Zend\ServiceManager\ServiceLocatorInterface;
10
11
class CacheFactory implements FactoryInterface
12
{
13
    /**
14
     * Create service
15
     *
16
     * @param ServiceLocatorInterface $serviceLocator
17
     * @return StorageInterface
18
     */
19 1
    public function createService(ServiceLocatorInterface $serviceLocator)
20
    {
21 1
        $config = $serviceLocator->get('config')['mxdimodule'];
22
23 1
        $cache = StorageFactory::adapterFactory(
24 1
            $config['cache_adapter'],
25 1
            $config['cache_options']
26 1
        );
27
28 1
        if ($cache instanceof AbstractAdapter) {
29 1
            $cache->addPlugin(new Serializer());
30 1
        }
31
32 1
        return $cache;
33
    }
34
}
35