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:52
created

LocatorAssembler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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->getConfiguration();
44
45
            $srcNS = $assembler->getNamespace($config);
46
            $specPrefix = $assembler->getSpecPrefix($config);
47
            $srcPath = $assembler->getSrcPath($config);
48
            $specPath = $assembler->getSpecPath($config);
49
            $codePool = $assembler->getCodePool($config);
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
    public function getNamespace(array $config)
100
    {
101
        return array_key_exists('namespace', $config) ? $config['namespace'] : '';
102
    }
103
104
    public function getSpecPrefix(array $config)
105
    {
106
        return array_key_exists('spec_prefix', $config) ? $config['spec_prefix'] : '';
107
    }
108
109
    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...
110
    {
111
        return array_key_exists('src_path', $config) ? rtrim($config['src_path'], '/') . DIRECTORY_SEPARATOR : 'src';
112
    }
113
114
    public function getSpecPath(array $config)
115
    {
116
        return array_key_exists('spec_path', $config) ? rtrim($config['spec_path'], '/') . DIRECTORY_SEPARATOR : '.';
117
    }
118
119
    public function getCodePool(array $config)
120
    {
121
        return array_key_exists('code_pool', $config) ? $config['code_pool'] : 'local';
122
    }
123
}
124