CacheWarmer::isOptional()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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\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