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

RouteHandlerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 6
dl 44
loc 44
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B createService() 31 31 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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