Completed
Push — master ( 8c5b1a...9a26dd )
by Tomáš
17:38
created

ConfigurationResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 88.89%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 2
c 3
b 1
f 2
lcom 1
cbo 4
dl 0
loc 26
ccs 8
cts 9
cp 0.8889
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveFromContainerBuilder() 0 15 2
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\DefaultAutowire\Config\Definition;
9
10
use Symfony\Component\Config\Definition\Processor;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle;
13
14
final class ConfigurationResolver
15
{
16
    /**
17
     * @var string[]
18
     */
19
    private $resolvedConfiguration;
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 5
    public function resolveFromContainerBuilder(ContainerBuilder $containerBuilder)
25
    {
26 5
        if ($this->resolvedConfiguration) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->resolvedConfiguration of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
27
            return $this->resolvedConfiguration;
28
        }
29
30 5
        $processor = new Processor();
31 5
        $configs = $containerBuilder->getExtensionConfig(SymplifyDefaultAutowireBundle::ALIAS);
32 5
        $configs = $processor->processConfiguration(new Configuration(), $configs);
33
34 5
        $this->resolvedConfiguration = $containerBuilder->getParameterBag()
35 5
            ->resolveValue($configs);
36
37 5
        return $this->resolvedConfiguration;
38
    }
39
}
40