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.

ControllerLocator::supportsClass()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
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\Locator\Magento;
23
24
use InvalidArgumentException;
25
use PhpSpec\Locator\ResourceLocator as ResourceLocatorInterface;
26
use PhpSpec\Util\Filesystem;
27
28
/**
29
 * ControllerLocator
30
 *
31
 * @category   MageTest
32
 * @package    PhpSpec_MagentoExtension
33
 *
34
 * @author     MageTest team (https://github.com/MageTest/MageSpec/contributors)
35
 */
36
class ControllerLocator extends AbstractResourceLocator implements ResourceLocatorInterface
37
{
38
    /**
39
     * @param string $classname
40
     * @return bool
41
     */
42
    public function supportsClass($classname)
43
    {
44
        return ($this->supportsQuery($classname) || preg_match('/Controller$/', $classname));
45
    }
46
47
    /**
48
     * @return int
49
     */
50
    public function getPriority()
51
    {
52
        return 10;
53
    }
54
55
    /**
56
     * @param string $file
57
     * @return bool
58
     */
59
    protected function isSupported($file)
60
    {
61
        return strpos($file, 'controllers') > 0;
62
    }
63
64
    /**
65
     * @param array $parts
66
     * @param ResourceLocatorInterface $locator
67
     * @return ControllerResource
68
     * @throws \InvalidArgumentException
69
     */
70
    protected function getResource(array $parts, ResourceLocatorInterface $locator)
71
    {
72
        if (!$locator instanceof ControllerLocator) {
73
            throw new \InvalidArgumentException('Controller resource requires a controller locator');
74
        }
75
        return new ControllerResource($parts, $locator);
76
    }
77
78
    /**
79
     * @param array $matches
80
     * @return string
81
     */
82
    protected function getObjectName(array $matches)
83
    {
84
        return implode('_', array_map('ucfirst', explode('_', implode($matches)))).'Controller';
85
    }
86
87
    /**
88
     * @param string $path
89
     * @return string
90
     */
91
    protected function getRelative($path)
92
    {
93
        $relative = parent::getRelative($path);
94
        return str_replace(
95
            DIRECTORY_SEPARATOR . $this->getClassType() . DIRECTORY_SEPARATOR,
96
            DIRECTORY_SEPARATOR,
97
            $relative
98
        );
99
    }
100
101
    /**
102
     * @return string
103
     */
104
    protected function getClassType()
105
    {
106
        return 'controllers';
107
    }
108
109
    /**
110
     * @return string
111
     */
112
    protected function getValidator()
113
    {
114
        return '/^(controller):([a-zA-Z0-9]+)_([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$/';
115
    }
116
}
117