L10nResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace L10nBundle\Utils\Resolver;
4
5
use Symfony\Component\DependencyInjection\Container;
6
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
7
8
/**
9
 * Resolves the parameters that are used in a value
10
 */
11
class L10nResolver
12
{
13
    /**
14
     * @var ParameterBagInterface
15
     */
16
    protected $parameterBag;
17
18
    /**
19
     * @param Container $container
20
     */
21 4
    public function __construct(Container $container)
22
    {
23 4
        $parameterBag = $container->getParameterBag();
24 4
        $parameterBag->resolve();
25
26 4
        $this->parameterBag = $parameterBag;
27 4
    }
28
29
    /**
30
     * Resolves a value containing parameters to a plain value.
31
     *
32
     * @param mixed $value
33
     *
34
     * @return mixed
35
     */
36 4
    public function resolve($value)
37
    {
38 4
        if (!is_array($value)) {
39 3
            return $this->parameterBag->resolveValue($value);
40
        }
41
42 1
        return null;
43
    }
44
}
45