CacheClearControllerFactory::createService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
namespace mxdiModule\Factory\Controller;
3
4
use mxdiModule\Controller\CacheClearController;
5
use Zend\Cache\Storage\StorageInterface;
6
use Zend\ServiceManager\AbstractPluginManager;
7
use Zend\ServiceManager\FactoryInterface;
8
use Zend\ServiceManager\ServiceLocatorInterface;
9
10
class CacheClearControllerFactory implements FactoryInterface
11
{
12
    /**
13
     * @param ServiceLocatorInterface $serviceLocator
14
     * @return CacheClearController
15
     */
16 1
    public function createService(ServiceLocatorInterface $serviceLocator)
17
    {
18 1
        if ($serviceLocator instanceof AbstractPluginManager) {
19 1
            $serviceLocator = $serviceLocator->getServiceLocator();
20 1
        }
21
22
        /** @var StorageInterface $storage */
23 1
        $storage = $serviceLocator->get('mxdiModule\Cache');
24
25 1
        return new CacheClearController($storage);
26
    }
27
}
28