Passed
Push — master ( a410d2...4ae760 )
by Matt
02:02
created

EnvVarExtension::load()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 4
nop 2
crap 3
1
<?php
2
/**
3
 * EnvVarExtension.php
4
 * Definition of class EnvVarExtension
5
 *
6
 * Created Nov 8, 2016, 2:39:05 PM
7
 * 
8
 * @author Matt Ward <[email protected]>
9
 */
10
11
namespace Mdjward\Behat\EnvVarExtension\ServiceContainer;
12
13
use Behat\Testwork\ServiceContainer\Extension;
14
use Behat\Testwork\ServiceContainer\ExtensionManager;
15
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * EnvVarExtension
20
 *
21
 * @author Matt Ward <[email protected]>
22
 */
23
class EnvVarExtension implements Extension
24
{
25
26
    /**
27
     * 
28
     * @param ArrayNodeDefinition $builder
29
     */
30 2
    public function configure(ArrayNodeDefinition $builder)
31
    {
32
        $builder
33 2
            ->children()
34 2
            ->scalarNode('prefix')
35 2
            ->defaultValue('env')
36
        ;
37 2
    }
38
39
    /**
40
     * 
41
     * @return string
42
     */
43 4
    public function getConfigKey()
44
    {
45 4
        return 'env_var';
46
    }
47
48
    /**
49
     * 
50
     * @param ExtensionManager $extensionManager
51
     */
52 1
    public function initialize(ExtensionManager $extensionManager)
53
    {
54 1
    }
55
56
    /**
57
     * 
58
     * @param ContainerBuilder $container
59
     * @param array $config
60
     */
61 1
    public function load(ContainerBuilder $container, array $config)
62
    {
63 1
        $prefix = (empty($config['prefix']) ? '' : $config['prefix'] . '.');
64
65 1
        foreach (filter_input_array(INPUT_SERVER) as $name => $value) {
66 1
            $container->setParameter($prefix . strtolower($name), $value);
67 1
        }
68 1
    }
69
70
    /**
71
     * 
72
     * @param ContainerBuilder $container
73
     */
74 1
    public function process(ContainerBuilder $container)
75
    {
76 1
    }
77
78
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
79