Completed
Push — master ( 6cec30...bddb48 )
by nicolas
11s
created

ConfigFileCacheWarmer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isOptional() 0 4 1
A warmUp() 0 4 1
1
<?php
2
3
namespace Dekalee\AdbackAnalyticsBundle\CacheWarmer;
4
5
use Dekalee\AdbackAnalytics\Query\ScriptUrlQuery;
6
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
7
8
/**
9
 * Class ConfigFileCacheWarmer
10
 */
11
class ConfigFileCacheWarmer implements CacheWarmerInterface
12
{
13
    protected $query;
14
15
    /**
16
     * @param ScriptUrlQuery $query
17
     */
18
    public function __construct(ScriptUrlQuery $query)
19
    {
20
        $this->query = $query;
21
    }
22
23
    /**
24
     * Checks whether this warmer is optional or not.
25
     *
26
     * Optional warmers can be ignored on certain conditions.
27
     *
28
     * A warmer should return true if the cache can be
29
     * generated incrementally and on-demand.
30
     *
31
     * @return bool true if the warmer is optional, false otherwise
32
     */
33
    public function isOptional()
34
    {
35
        return false;
36
    }
37
38
    /**
39
     * Warms up the cache.
40
     *
41
     * @param string $cacheDir The cache directory
42
     */
43
    public function warmUp($cacheDir)
44
    {
45
        $this->query->execute();
46
    }
47
}
48