GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 2b724d...6bccab )
by Андрей
23:32 queued 20:15
created

DispatcherFactory::createService()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 19

Duplication

Lines 32
Ratio 100 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 32
loc 32
rs 8.8571
cc 2
eloc 19
nc 2
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/old-town/workflow-zf2-dispatch
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\ZF2\Dispatch\Dispatcher;
7
8
use OldTown\Workflow\ZF2\ServiceEngine\Workflow as WorkflowService;
9
use Zend\ServiceManager\FactoryInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
use OldTown\Workflow\ZF2\Dispatch\Options\ModuleOptions;
12
use OldTown\Workflow\ZF2\Dispatch\Metadata\MetadataReaderManager;
13
use Zend\Log\Logger;
14
use Zend\Log\Writer\Noop;
15
16
/**
17
 * Class DispatcherFactory
18
 *
19
 * @package OldTown\Workflow\ZF2\Dispatch\Dispatcher
20
 */
21 View Code Duplication
class DispatcherFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
    /**
24
     * @param ServiceLocatorInterface $serviceLocator
25
     *
26
     * @return Dispatcher
27
     *
28
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
29
     * @throws \OldTown\Workflow\ZF2\Dispatch\Listener\Exception\InvalidArgumentException
30
     * @throws \OldTown\Workflow\ZF2\Dispatch\Listener\Exception\MetadataReaderManagerException
31
     * @throws Exception\MetadataReaderManagerException
32
     * @throws \Zend\ServiceManager\Exception\RuntimeException
33
     * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException
34
     * @throws \Zend\Log\Exception\InvalidArgumentException
35
     */
36
    public function createService(ServiceLocatorInterface $serviceLocator)
37
    {
38
        $workflowService = $serviceLocator->get(WorkflowService::class);
39
40
        /** @var MetadataReaderManager $metadataReaderManager */
41
        $metadataReaderManager = $serviceLocator->get(MetadataReaderManager::class);
42
43
        /** @var ModuleOptions $moduleOptions */
44
        $moduleOptions = $serviceLocator->get(ModuleOptions::class);
45
46
        $metadataReader = $metadataReaderManager->get($moduleOptions->getDispatchMetadataReader());
47
48
        $validatorManager = $serviceLocator->get('ValidatorManager');
49
50
        $logName = $moduleOptions->getLogName();
51
        if (null === $logName) {
52
            $log = new Logger();
53
            $writer = new Noop();
54
            $log->addWriter($writer);
55
        } else {
56
            $log = $serviceLocator->get($logName);
57
        }
58
59
        $options = [
60
            'workflowService'  => $workflowService,
61
            'metadataReader'   => $metadataReader,
62
            'validatorManager' => $validatorManager,
63
            'log'              => $log
64
        ];
65
66
        return new Dispatcher($options);
67
    }
68
}
69