RestorableCachePass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 4
1
<?php
2
3
/*
4
 * This file is part of the ConfigCacheBundle package.
5
 *
6
 * Copyright (c) 2015-2016 Yahoo Japan Corporation
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace YahooJapan\ConfigCacheBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
use YahooJapan\ConfigCacheBundle\ConfigCache\RestorablePhpFileCache;
18
19
/**
20
 * RestorableCachePass is a service register pass to recreate the caches.
21
 */
22
class RestorableCachePass implements CompilerPassInterface
23
{
24
    protected $restorerId = 'yahoo_japan_config_cache.cache_restorer';
25
    protected $saverId    = 'yahoo_japan_config_cache.cache_saver';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 13
    public function process(ContainerBuilder $container)
31
    {
32 13
        if (!$container->hasDefinition($this->restorerId) || !$container->hasDefinition($this->saverId)) {
33 2
            return;
34
        }
35 11
        $restorer = $container->getDefinition($this->restorerId);
36 11
        $saver    = $container->getDefinition($this->saverId);
37
38 11
        foreach ($container->findTaggedServiceIds(RestorablePhpFileCache::TAG_RESTORABLE_CACHE) as $configCacheId => $attributes) {
39 1
            $restorer->addMethodCall('addConfig', array(new Reference($configCacheId)));
40 1
            $saver->addMethodCall('addConfig', array(new Reference($configCacheId)));
41 11
        }
42 11
    }
43
}
44