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
Pull Request — develop (#140)
by Max
02:07
created

LocatorAssembler::build()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 59
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 59
rs 9.597
c 0
b 0
f 0
cc 3
eloc 35
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * MageSpec
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the MIT License, that is bundled with this
8
 * package in the file LICENSE.
9
 * It is also available through the world-wide-web at this URL:
10
 *
11
 * http://opensource.org/licenses/MIT
12
 *
13
 * If you did not receive a copy of the license and are unable to obtain it
14
 * through the world-wide-web, please send an email
15
 * to <[email protected]> so we can send you a copy immediately.
16
 *
17
 * @category   MageTest
18
 * @package    PhpSpec_MagentoExtension
19
 *
20
 * @copyright  Copyright (c) 2012-2013 MageTest team and contributors.
21
 */
22
namespace MageTest\PhpSpec\MagentoExtension\Extension;
23
24
use MageTest\PhpSpec\MagentoExtension\Configuration\MageLocator;
25
use PhpSpec\ServiceContainer;
26
27
class LocatorAssembler implements Assembler
28
{
29
    private $configuration;
30
31
    public function __construct(MageLocator $configuration)
32
    {
33
        $this->configuration = $configuration;
34
    }
35
36
    /**
37
     * @param ServiceContainer $container
38
     */
39
    public function build(ServiceContainer $container)
40
    {
41
        $assembler = $this;
42
        $container->addConfigurator(function ($c) use ($assembler) {
43
            $config = $assembler->configuration;
44
45
            $srcNS = $config->getNamespace();
46
            $specPrefix = $config->getSpecPrefix();
47
            $srcPath = $config->getSrcPath();
48
            $specPath = $config->getSpecPath();
49
            $codePool = $config->getCodePool();
50
            $filesystem = $c->get('filesystem');
51
52
            if (!$filesystem->isDirectory($srcPath)) {
53
                $filesystem->makeDirectory($srcPath);
54
            }
55
56
            if (!$filesystem->isDirectory($specPath)) {
57
                $filesystem->makeDirectory($specPath);
58
            }
59
60
            $factory = new LocatorFactory($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
61
62
            $c->define('locator.locators.magento.model_locator',
63
                function () use ($factory) {
64
                    return $factory->getLocator('model');
65
                },
66
                ['locator.locators.magento']
67
            );
68
69
            $c->define('locator.locators.magento.block_locator',
70
                function () use ($factory) {
71
                    return $factory->getLocator('block');
72
                },
73
                ['locator.locators.magento']
74
            );
75
76
            $c->define('locator.locators.magento.helper_locator',
77
                function () use ($factory) {
78
                    return $factory->getLocator('helper');
79
                },
80
                ['locator.locators.magento']
81
            );
82
83
            $c->define('locator.locators.magento.controller_locator',
84
                function () use ($factory) {
85
                    return $factory->getLocator('controller');
86
                },
87
                ['locator.locators.magento']
88
            );
89
90
            $resourceManager = $c->get('locator.resource_manager');
91
92
            array_map(
93
                array($resourceManager, 'registerLocator'),
94
                $c->getByTag('locator.locators.magento')
95
            );
96
        });
97
    }
98
}
99