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   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 7
eloc 29
dl 0
loc 63
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 19 6
A configure() 0 22 1
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