Completed
Push — master ( 14cbb2...16a771 )
by MoshiMoshi
02:26
created

CacheWarmer::warmUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
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 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
class CacheWarmer implements CacheWarmerInterface
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 10
    public function isOptional()
40
    {
41 10
        return true;
42
    }
43
44
    /**
45
     * Adds a ConfigCache.
46
     *
47
     * @param ConfigCache $config
48
     *
49
     * @return CacheWarmerListener
50
     */
51 11
    public function addConfig(ConfigCache $config)
52
    {
53 11
        $this->configs[] = $config;
54
55 11
        return $this;
56
    }
57
}
58