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.

EntryIdResolverFactory::createService()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 31
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 31
rs 8.8571
cc 2
eloc 19
nc 2
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/old-town/workflow-zf2-toolkit
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\ZF2\Toolkit\WorkflowRunParams;
7
8
use Zend\Mvc\Application;
9
use Zend\ServiceManager\FactoryInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
use OldTown\Workflow\ZF2\Service\Service\Manager as WorkflowServiceManager;
12
use OldTown\Workflow\ZF2\Toolkit\EntryToObjects\EntryToObjectsService;
13
use OldTown\Workflow\ZF2\Toolkit\Options\ModuleOptions;
14
use Zend\Log\Logger;
15
use Zend\Log\Writer\Noop;
16
17
/**
18
 * Class EntryIdResolverFactory
19
 *
20
 * @package OldTown\Workflow\ZF2\Toolkit\WorkflowRunParams
21
 */
22
class EntryIdResolverFactory implements FactoryInterface
23
{
24
    /**
25
     * @param ServiceLocatorInterface $serviceLocator
26
     *
27
     * @return EntryIdResolver
28
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
29
     * @throws \Zend\ServiceManager\Exception\ServiceNotCreatedException
30
     * @throws \Zend\ServiceManager\Exception\RuntimeException
31
     * @throws \Zend\Log\Exception\InvalidArgumentException
32
     */
33
    public function createService(ServiceLocatorInterface $serviceLocator)
34
    {
35
        /** @var WorkflowServiceManager $wfServiceManager */
36
        $wfServiceManager = $serviceLocator->get(WorkflowServiceManager::class);
37
38
        /** @var EntryToObjectsService $entryToObjectsService */
39
        $entryToObjectsService = $wfServiceManager->get(EntryToObjectsService::class);
40
        $moduleOptions = $serviceLocator->get(ModuleOptions::class);
41
42
        /** @var Application $app */
43
        $app = $serviceLocator->get('Application');
44
        $mvcEvent = $app->getMvcEvent();
45
46
        $logName = $moduleOptions->getLogName();
47
        if (null === $logName) {
48
            $log = new Logger();
49
            $writer = new Noop();
50
            $log->addWriter($writer);
51
        } else {
52
            $log = $serviceLocator->get($logName);
53
        }
54
55
        $options = [
56
            'entryToObjectsService' => $entryToObjectsService,
57
            'moduleOptions'         => $moduleOptions,
58
            'mvcEvent'              => $mvcEvent,
59
            'log'                   => $log
60
        ];
61
62
        return new EntryIdResolver($options);
63
    }
64
}
65