CacheWarmer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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 CacheWarmer warm-ups the caches that are tagged ConfigCache services.
19
 */
20 View Code Duplication
class CacheWarmer 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
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
28
     */
29 1
    public function warmUp($cacheDir)
30
    {
31 1
        foreach ($this->configs as $config) {
32 1
            $config->create();
33 1
        }
34 1
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 11
    public function isOptional()
40
    {
41 11
        return true;
42
    }
43
44
    /**
45
     * Adds a ConfigCache.
46
     *
47
     * @param ConfigCache $config
48
     *
49
     * @return CacheWarmerListener
50
     */
51 12
    public function addConfig(ConfigCache $config)
52
    {
53 12
        $this->configs[] = $config;
54
55 12
        return $this;
56
    }
57
}
58