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.

ModelElement   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 0
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A addElementToXml() 0 18 3
1
<?php
2
3
namespace MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\Element;
4
5
use MageTest\PhpSpec\MagentoExtension\CodeGenerator\Generator\Xml\XmlGeneratorException;
6
7
class ModelElement extends SimpleElementAbstract implements ConfigElementInterface
8
{
9
    /**
10
     * @param string $type
11
     * @return boolean
12
     */
13
    public function supports($type)
14
    {
15
        return $type === 'model';
16
    }
17
18
    /**
19
     * @param \SimpleXMLElement $xml
20
     * @param string $type
21
     * @param string $moduleName
22
     * @throws XmlGeneratorException
23
     * @return null
24
     */
25
    public function addElementToXml(\SimpleXMLElement $xml, $type, $moduleName)
26
    {
27
        $globalElements = $xml->xpath('/config/global');
28
29
        if (!count($globalElements)) {
30
            throw new XmlGeneratorException(sprintf('Global element not found in %s config file', $moduleName));
31
        }
32
33
        $modelsElement = $this->getElement($globalElements[0], 'models');
34
35
        $modelsClassContainer = $modelsElement->addChild(strtolower($moduleName));
36
        $modelsClassContainer->addChild('class', $moduleName . '_' . ucfirst($type));
37
38
        $resourceElementName = strtolower($moduleName).'_resource';
39
        if (count($modelsElement->xpath($resourceElementName))) {
40
            $modelsClassContainer->addChild('resourceModel', $resourceElementName);
41
        }
42
    }
43
}
44