CachePass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 5
c 1
b 1
f 0
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 5
cp 0.6
crap 2.2559
rs 10
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\UrlBundle\DependencyInjection\Compiler;
7
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
/**
12
 * Replaces the url provider with a cache wrapper, if enabled.
13
 */
14
class CachePass implements CompilerPassInterface
15
{
16
    /**
17
     * @{inheritDoc}
18
     */
19 1
    public function process(ContainerBuilder $container)
20
    {
21 1
        if ($container->hasDefinition('zicht_url.cache')) {
22
            $container->setAlias('zicht_url.provider', 'zicht_url.cache_wrapper');
23
            $container->getDefinition('zicht_url.cache')->addTag('zicht_cache.cache_stats');
24
        } else {
25 1
            $container->setAlias('zicht_url.provider', 'zicht_url.provider.delegator');
26
        }
27 1
    }
28
}
29