L10nResolver::resolve()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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