CacheSaver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 6 2
A isOptional() 0 4 1
A addConfig() 0 6 1
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\CacheClearer;
13
14
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
15
use YahooJapan\ConfigCacheBundle\ConfigCache\ConfigCache;
16
17
/**
18
 * The CacheSaver saves cache files to the temporary directory.
19
 */
20
class CacheSaver implements CacheClearerInterface
21
{
22
    protected $configs = array();
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function clear($cacheDir)
28
    {
29 1
        foreach ($this->configs as $config) {
30 1
            $config->save();
31 1
        }
32 1
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function isOptional()
38
    {
39 1
        return true;
40
    }
41
42
    /**
43
     * Adds a ConfigCache with RestorablePhpFileCache.
44
     *
45
     * @param ConfigCache $config
46
     *
47
     * @return CacheSaver
48
     */
49 2
    public function addConfig(ConfigCache $config)
50
    {
51 2
        $this->configs[] = $config;
52
53 2
        return $this;
54
    }
55
}
56