VoterCacheWarmer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A warmUp() 0 6 2
A isOptional() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\CoreBundle\CacheWarmer;
22
23
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
24
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
25
use Tenside\CoreBundle\Security\PermissionVoter;
26
27
/**
28
 * Generates the route access voter cache
29
 */
30
class VoterCacheWarmer implements CacheWarmerInterface
31
{
32
    /**
33
     * The voter.
34
     *
35
     * @var PermissionVoter
36
     */
37
    protected $voter;
38
39
    /**
40
     * Constructor.
41
     *
42
     * @param PermissionVoter $voter A voter instance.
43
     */
44
    public function __construct(PermissionVoter $voter)
45
    {
46
        $this->voter = $voter;
47
    }
48
49
    /**
50
     * Warms up the cache.
51
     *
52
     * @param string $cacheDir The cache directory.
53
     *
54
     * @return void
55
     */
56
    public function warmUp($cacheDir)
57
    {
58
        if ($this->voter instanceof WarmableInterface) {
59
            $this->voter->warmUp($cacheDir);
60
        }
61
    }
62
63
    /**
64
     * Checks whether this warmer is optional or not.
65
     *
66
     * @return bool always true
67
     */
68
    public function isOptional()
69
    {
70
        return true;
71
    }
72
}
73