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

resolveFromContainerBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2.0054

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 15
ccs 8
cts 9
cp 0.8889
rs 9.4285
cc 2
eloc 9
nc 2
nop 1
crap 2.0054
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