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.
Test Failed
Push — dev ( 2b724d...6bccab )
by Андрей
21:02
created

RouteHandlerFactory::createService()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 31
Code Lines 18

Duplication

Lines 31
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 31
loc 31
rs 8.8571
cc 2
eloc 18
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\RunParamsHandler;
7
8
use Zend\ServiceManager\FactoryInterface;
9
use Zend\ServiceManager\ServiceLocatorInterface;
10
use OldTown\Workflow\ZF2\Dispatch\Options\ModuleOptions;
11
use OldTown\Workflow\ZF2\Dispatch\Metadata\MetadataReaderManager;
12
use Zend\Log\Logger;
13
use Zend\Log\Writer\Noop;
14
use OldTown\Workflow\ZF2\ServiceEngine\Workflow;
15
use OldTown\Workflow\ZF2\ServiceEngine\WorkflowServiceInterface;
16
17
/**
18
 * Class RouteHandlerFactory
19
 *
20
 * @package OldTown\Workflow\ZF2\Dispatch\RunParamsHandler
21
 */
22 View Code Duplication
class RouteHandlerFactory 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...
23
{
24
    /**
25
     * @param ServiceLocatorInterface $serviceLocator
26
     *
27
     * @return RouteHandler
28
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
29
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
30
     * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException
31
     * @throws \Zend\ServiceManager\Exception\RuntimeException
32
     * @throws \Zend\Log\Exception\InvalidArgumentException
33
     */
34
    public function createService(ServiceLocatorInterface $serviceLocator)
35
    {
36
        /** @var ModuleOptions $moduleOptions */
37
        $moduleOptions = $serviceLocator->get(ModuleOptions::class);
38
39
        $readerName = $moduleOptions->getRunWorkflowParamsMetadataReader();
40
        /** @var MetadataReaderManager $readerManager */
41
        $readerManager = $serviceLocator->get(MetadataReaderManager::class);
42
43
        $reader = $readerManager->get($readerName);
44
45
        $logName = $moduleOptions->getLogName();
46
        if (null === $logName) {
47
            $log = new Logger();
48
            $writer = new Noop();
49
            $log->addWriter($writer);
50
        } else {
51
            $log = $serviceLocator->get($logName);
52
        }
53
54
        /** @var WorkflowServiceInterface $workflowService */
55
        $workflowService = $serviceLocator->get(Workflow::class);
56
57
        $options = [
58
            'metadataReader' => $reader,
59
            'workflowService' => $workflowService,
60
            'log' => $log
61
        ];
62
63
        return new RouteHandler($options);
64
    }
65
}
66