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
24:34
created

LocatorAssembler   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 15
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 97
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B build() 0 59 4
A getNamespace() 0 4 2
A getSpecPrefix() 0 4 2
A getSrcPath() 0 4 2
A getSpecPath() 0 4 2
A getCodePool() 0 4 2
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\Locator\Magento\BlockLocator;
25
use MageTest\PhpSpec\MagentoExtension\Locator\Magento\ControllerLocator;
26
use MageTest\PhpSpec\MagentoExtension\Locator\Magento\HelperLocator;
27
use MageTest\PhpSpec\MagentoExtension\Locator\Magento\ModelLocator;
28
use PhpSpec\Locator\ResourceManager;
29
use PhpSpec\ServiceContainer;
30
31
class LocatorAssembler implements Assembler
32
{
33
    private $params;
34
35
    public function __construct(array $params  = [])
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$params" and equals sign; expected 1 but found 2
Loading history...
36
    {
37
        $this->params = $params;
38
    }
39
40
    /**
41
     * @param ServiceContainer $container
42
     */
43
    public function build(ServiceContainer $container)
44
    {
45
        $assembler = $this;
46
        $container->addConfigurator(function ($c) use ($assembler) {
47
            $config = isset($assembler->params['mage_locator']) ? $assembler->params['mage_locator'] : $c->getParam('mage_locator',  array('main' => ''));
0 ignored issues
show
Coding Style introduced by
Expected 1 space instead of 2 after comma in function call.
Loading history...
48
49
            $srcNS = $assembler->getNamespace($config);
50
            $specPrefix = $assembler->getSpecPrefix($config);
51
            $srcPath = $assembler->getSrcPath($config);
52
            $specPath = $assembler->getSpecPath($config);
53
            $codePool = $assembler->getCodePool($config);
54
            $filesystem = $c->get('filesystem');
55
56
            if (!$filesystem->isDirectory($srcPath)) {
57
                $filesystem->makeDirectory($srcPath);
58
            }
59
60
            if (!$filesystem->isDirectory($specPath)) {
61
                $filesystem->makeDirectory($specPath);
62
            }
63
64
            $factory = new LocatorFactory($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool);
65
66
            $c->define('locator.locators.magento.model_locator',
67
                function () use ($factory) {
68
                    return $factory->getLocator('model');
69
                },
70
                ['locator.locators.magento']
71
            );
72
73
            $c->define('locator.locators.magento.block_locator',
74
                function () use ($factory) {
75
                    return $factory->getLocator('block');
76
                },
77
                ['locator.locators.magento']
78
            );
79
80
            $c->define('locator.locators.magento.helper_locator',
81
                function () use ($factory) {
82
                    return $factory->getLocator('helper');
83
                },
84
                ['locator.locators.magento']
85
            );
86
87
            $c->define('locator.locators.magento.controller_locator',
88
                function () use ($factory) {
89
                    return $factory->getLocator('controller');
90
                },
91
                ['locator.locators.magento']
92
            );
93
94
            $resourceManager = $c->get('locator.resource_manager');
95
96
            array_map(
97
                array($resourceManager, 'registerLocator'),
98
                $c->getByTag('locator.locators.magento')
99
            );
100
        });
101
    }
102
103
    public function getNamespace(array $config)
104
    {
105
        return array_key_exists('namespace', $config) ? $config['namespace'] : '';
106
    }
107
108
    public function getSpecPrefix(array $config)
109
    {
110
        return array_key_exists('spec_prefix', $config) ? $config['spec_prefix'] : '';
111
    }
112
113
    public function getSrcPath(Array $config)
0 ignored issues
show
Coding Style introduced by
As per coding-style, PHP keywords should be in lowercase; expected array, but found Array.
Loading history...
114
    {
115
        return array_key_exists('src_path', $config) ? rtrim($config['src_path'], '/') . DIRECTORY_SEPARATOR : 'src';
116
    }
117
118
    public function getSpecPath(array $config)
119
    {
120
        return array_key_exists('spec_path', $config) ? rtrim($config['spec_path'], '/') . DIRECTORY_SEPARATOR : '.';
121
    }
122
123
    public function getCodePool(array $config)
124
    {
125
        return array_key_exists('code_pool', $config) ? $config['code_pool'] : 'local';
126
    }
127
}
128