SuiteSettingsExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 49
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigKey() 0 4 1
A initialize() 0 3 1
A configure() 0 10 1
A load() 0 7 1
A process() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the SuiteSettingsExtension package.
7
 *
8
 * (c) Kamil Kokot <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace FriendsOfBehat\SuiteSettingsExtension\ServiceContainer;
15
16
use Behat\Testwork\ServiceContainer\Extension;
17
use Behat\Testwork\ServiceContainer\ExtensionManager;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
21
final class SuiteSettingsExtension implements Extension
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getConfigKey(): string
27
    {
28
        return 'fob_suite_settings';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function initialize(ExtensionManager $extensionManager): void
35
    {
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function configure(ArrayNodeDefinition $builder): void
42
    {
43
        $builder
44
            ->validate()
45
                ->ifTrue(function ($value) { return !is_array($value); })
46
                ->thenInvalid('Configuration should be an array')
47
        ;
48
49
        $builder->prototype('variable')->defaultValue([]);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function load(ContainerBuilder $container, array $config): void
56
    {
57
        $container->setParameter('suite.generic.default_settings', array_merge(
58
            $container->getParameter('suite.generic.default_settings'),
59
            $config
60
        ));
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function process(ContainerBuilder $container): void
67
    {
68
    }
69
}
70