Passed
Push — master ( b74a1f...762e12 )
by MoshiMoshi
03:10
created

CacheRestorer::warmUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 6
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
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\CacheWarmer;
13
14
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
15
use YahooJapan\ConfigCacheBundle\ConfigCache\ConfigCache;
16
17
/**
18
 * The CacheRestorer restores cache files to the cache directory.
19
 */
20 View Code Duplication
class CacheRestorer implements CacheWarmerInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    protected $configs = array();
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function warmUp($cacheDir)
28
    {
29 1
        foreach ($this->configs as $config) {
30 1
            $config->restore();
31 1
        }
32 1
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 11
    public function isOptional()
38
    {
39 11
        return true;
40
    }
41
42
    /**
43
     * Adds a ConfigCache with RestorablePhpFileCache.
44
     *
45
     * @param ConfigCache $config
46
     *
47
     * @return CacheRestorer
48
     */
49 2
    public function addConfig(ConfigCache $config)
50
    {
51 2
        $this->configs[] = $config;
52
53 2
        return $this;
54
    }
55
}
56