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 — master (#101)
by Patrick
05:09
created

ChapiConfigLoader::loadProfileParameters()   B

Complexity

Conditions 6
Paths 7

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 8.5906
c 0
b 0
f 0
cc 6
eloc 11
nc 7
nop 0
crap 6
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2017-03-20
7
 *
8
 */
9
10
namespace Chapi\Component\DependencyInjection\Loader;
11
12
use Chapi\Component\Config\ChapiConfigInterface;
13
use \InvalidArgumentException;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
16
class ChapiConfigLoader implements ChapiConfigLoaderInterface
17
{
18
    /**
19
     * @var ContainerBuilder
20
     */
21
    private $container;
22
23
    /**
24
     * @var ChapiConfigInterface
25
     */
26
    private $config;
27
28
    /**
29
     * ChapiConfigLoader constructor.
30
     * @param ContainerBuilder $container
31
     * @param ChapiConfigInterface $config
32
     */
33 3
    public function __construct(ContainerBuilder $container, ChapiConfigInterface $config)
34
    {
35 3
        $this->container = $container;
36 3
        $this->config = $config;
37 3
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42 3
    public function loadProfileParameters()
43
    {
44 3
        $content = $this->config->getProfileConfig();
45
46 3
        $this->container->addObjectResource($this->config);
47
48
        // empty config
49 3
        if (empty($content)) {
50 1
            return;
51
        }
52
53 2
        foreach ($content['parameters'] as &$parameter) {
54 1
            if ($parameter === null || $parameter === 'null') {
55 1
                $parameter = '';
56
            }
57
        }
58
59
        // parameters
60 1
        if (isset($content['parameters'])) {
61 1
            $this->validate($content);
62 1
            $this->setParameters($content['parameters']);
63
        }
64 1
    }
65
66
    /**
67
     * @param array $content
68
     * @throws InvalidArgumentException
69
     * @return void
70
     */
71 1
    private function validate(array &$content)
72
    {
73 1
        if (isset($content['parameters']) && !is_array($content['parameters'])) {
74
            throw new InvalidArgumentException('The "parameters" key should contain an array. Please check your configuration files.');
75
        }
76 1
    }
77
78
    /**
79
     * @param array $parameters
80
     */
81 1
    private function setParameters(array &$parameters)
82
    {
83 1
        foreach ($parameters as $key => $value) {
84 1
            $this->container->setParameter($key, $value);
85
        }
86 1
    }
87
}
88