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

resolveFromContainerBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

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