Completed
Pull Request — master (#4)
by Timothy
08:48 queued 02:25
created

AbstractCheckCommandFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 5
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 17 3
getCommandServiceName() 0 1 ?
1
<?php
2
3
namespace Abacaphiliac\DoctrineORMDiagnosticsModule;
4
5
use DoctrineModule\Component\Console\Input\RequestInput;
6
use DoctrineModule\Component\Console\Output\PropertyOutput;
7
use Symfony\Component\Console\Command\Command;
8
use Zend\Console\Request;
9
use Zend\ServiceManager\FactoryInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
12
abstract class AbstractCheckCommandFactory implements FactoryInterface
13
{
14
    /**
15
     * Create service
16
     *
17
     * @param ServiceLocatorInterface $serviceLocator
18
     * @return CheckCommand
19
     * @throws \UnexpectedValueException
20
     * @throws \Zend\Console\Exception\RuntimeException
21
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
22
     */
23 6
    public function createService(ServiceLocatorInterface $serviceLocator)
24
    {
25 6
        $command = $serviceLocator->get($this->getCommandServiceName());
26 6
        if (!$command instanceof Command) {
27 1
            throw new \UnexpectedValueException(sprintf(
28 1
                'Expected type [%s]. Actual type [%s].',
29 1
                Command::class,
30 1
                is_object($command) ? get_class($command) : gettype($command)
31 1
            ));
32
        }
33
        
34 5
        $input = new RequestInput(new Request(array()));
35
        
36 5
        $output = new PropertyOutput();
37
        
38 5
        return new CheckCommand($command, $input, $output);
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    abstract public function getCommandServiceName();
45
}
46