Completed
Push — master ( 4b95a7...4b5b01 )
by Tomáš
04:20
created

ConfigurationResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveFromContainerBuilder() 0 13 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 6
    public function resolveFromContainerBuilder(ContainerBuilder $containerBuilder) : array
22
    {
23 6
        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...
24 1
            return $this->resolvedConfiguration;
25
        }
26
27 6
        $processor = new Processor();
28 6
        $configs = $containerBuilder->getExtensionConfig(SymplifyDefaultAutowireBundle::ALIAS);
29 6
        $configs = $processor->processConfiguration(new Configuration(), $configs);
30
31 6
        return $this->resolvedConfiguration = $containerBuilder->getParameterBag()
32 6
            ->resolveValue($configs);
33
    }
34
}
35