SuiteSettingsExtension::getConfigKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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