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.

BootstrapService::load()   A
last analyzed

Complexity

Conditions 6
Paths 12

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 6.027

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
ccs 10
cts 11
cp 0.9091
rs 9.2222
c 0
b 0
f 0
cc 6
nc 12
nop 1
crap 6.027
1
<?php
2
3
namespace AndreyOrs\BehatBootstrap;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
7
class BootstrapService
8
{
9
    /**
10
     * @const
11
     */
12
    const CONFIGURATION_KEY = 'bootstrap';
13
14
    /**
15
     * @param ArrayNodeDefinition $definition
16
     *
17
     * @throws \RuntimeException
18
     *
19
     * @codeCoverageIgnore
20
     */
21
    public function configure(ArrayNodeDefinition $definition)
22
    {
23
        $definition
24
            ->children()
25
                ->arrayNode(self::CONFIGURATION_KEY)
26
                    ->prototype('array')
27
                        ->beforeNormalization()
28
                            ->ifString()
29
                                ->then(function ($v) {
30
                                    return [
31
                                        'command' => $v,
32
                                    ];
33
                                })
34
                    ->end()
35
                    ->children()
36
                        ->scalarNode('command')
37
                            ->isRequired()
38
                            ->end()
39
                        ->end()
40
                    ->end()
41
                ->end()
42
            ->end();
43
    }
44
45
    /**
46
     * Include configured bootstrap file.
47
     *
48
     * @param array $config
49
     * @return bool
50
     */
51 4
    public function load(array $config)
52
    {
53 4
        $commands = \array_key_exists(self::CONFIGURATION_KEY, $config)
54 2
            ? $config[self::CONFIGURATION_KEY]
55 4
            : [];
56
57 4
        if (empty($commands)) {
58 3
            return false;
59
        }
60
61 1
        foreach ($commands as $cmd) {
62 1
            $cmd = \array_key_exists('command', $cmd) ? $cmd['command'] : null;
63
64 1
            if (null !== $cmd) {
65
                shell_exec($cmd);
66
            }
67
        }
68
69 1
        return true;
70
    }
71
}
72