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.

ControllerElement::supports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\Element;
4
5
class ControllerElement extends SimpleElementAbstract implements ConfigElementInterface
6
{
7
    /**
8
     * @param string $type
9
     * @return boolean
10
     */
11
    public function supports($type)
12
    {
13
        return $type === 'controller';
14
    }
15
16
    /**
17
     * @param \SimpleXMLElement $xml
18
     * @param string $type
19
     * @param string $moduleName
20
     * @return \SimpleXmlElement
21
     */
22
    public function addElementToXml(\SimpleXMLElement $xml, $type, $moduleName)
23
    {
24
        $frontendElement = $this->getElement($xml, 'frontend');
25
        $routersElement = $this->getElement($frontendElement, 'routers');
26
        $moduleElement = $this->getElement($routersElement, $this->getModuleRouteName($moduleName));
27
        $moduleElement->addChild('use', 'standard');
28
        $argsElement = $moduleElement->addChild('args');
29
        $argsElement->addChild('module', $moduleName);
30
        $argsElement->addChild('frontName', $this->getModuleRouteName($moduleName));
31
    }
32
33
    /**
34
     * @param \SimpleXMLElement $xml
35
     * @param string $type
36
     * @param string $moduleName
37
     * @return boolean
38
     */
39
    public function elementExistsInXml(\SimpleXMLElement $xml, $type, $moduleName)
40
    {
41
        $targetElements = $xml->xpath('/config/frontend/routers/' . $this->getModuleRouteName($moduleName));
42
        return (bool) count($targetElements);
43
    }
44
45
    /**
46
     * @param string $moduleName
47
     * @return string
48
     */
49
    private function getModuleRouteName($moduleName)
50
    {
51
        $parts = explode('_', $moduleName);
52
        return strtolower($parts[1]);
53
    }
54
}
55