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

CacheRestorer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A warmUp() 6 6 2
A isOptional() 4 4 1
A addConfig() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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