Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — master (#235)
by Jérémiah
10:32
created

XmlParser::parse()   B

Complexity

Conditions 5
Paths 10

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 14
nc 10
nop 2
crap 5
1
<?php
2
3
namespace Overblog\GraphQLBundle\Config\Parser;
4
5
use Symfony\Component\Config\Resource\FileResource;
6
use Symfony\Component\Config\Util\XmlUtils;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
9
use Symfony\Component\Finder\SplFileInfo;
10
11
class XmlParser implements ParserInterface
12
{
13
    /**
14
     * @param SplFileInfo      $file
15
     * @param ContainerBuilder $container
16
     *
17
     * @return array
18
     */
19 2
    public static function parse(SplFileInfo $file, ContainerBuilder $container)
20
    {
21 2
        $typesConfig = [];
22
23
        try {
24 2
            $xml = XmlUtils::loadFile($file->getRealPath());
25 1
            foreach ($xml->documentElement->childNodes as $node) {
26 1
                if (!$node instanceof \DOMElement) {
27 1
                    continue;
28
                }
29 1
                $values = XmlUtils::convertDomElementToArray($node);
30 1
                if (is_array($values)) {
31 1
                    $typesConfig = array_merge($typesConfig, $values);
32
                }
33
            }
34 1
            $container->addResource(new FileResource($file->getRealPath()));
35 1
        } catch (\InvalidArgumentException $e) {
36 1
            throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
37
        }
38
39 1
        return $typesConfig;
40
    }
41
}
42