Code Duplication    Length = 36-38 lines in 2 locations

CacheWarmer/CacheRestorer.php 1 location

@@ 20-55 (lines=36) @@
17
/**
18
 * The CacheRestorer restores cache files to the cache directory.
19
 */
20
class CacheRestorer implements CacheWarmerInterface
21
{
22
    protected $configs = array();
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function warmUp($cacheDir)
28
    {
29
        foreach ($this->configs as $config) {
30
            $config->restore();
31
        }
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function isOptional()
38
    {
39
        return true;
40
    }
41
42
    /**
43
     * Adds a ConfigCache with RestorablePhpFileCache.
44
     *
45
     * @param ConfigCache $config
46
     *
47
     * @return CacheRestorer
48
     */
49
    public function addConfig(ConfigCache $config)
50
    {
51
        $this->configs[] = $config;
52
53
        return $this;
54
    }
55
}
56

CacheWarmer/CacheWarmer.php 1 location

@@ 20-57 (lines=38) @@
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
    public function warmUp($cacheDir)
30
    {
31
        foreach ($this->configs as $config) {
32
            $config->create();
33
        }
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function isOptional()
40
    {
41
        return true;
42
    }
43
44
    /**
45
     * Adds a ConfigCache.
46
     *
47
     * @param ConfigCache $config
48
     *
49
     * @return CacheWarmerListener
50
     */
51
    public function addConfig(ConfigCache $config)
52
    {
53
        $this->configs[] = $config;
54
55
        return $this;
56
    }
57
}
58