Cache::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Happyr\DoctrineSpecification\Result;
15
16
use Doctrine\ORM\AbstractQuery;
17
18
class Cache implements ResultModifier
19
{
20
    /**
21
     * @var int How may seconds the cache entry is valid
22
     */
23
    private $cacheLifetime;
24
25
    /**
26
     * @param int $cacheLifetime How many seconds the cached entry is valid
27
     */
28
    public function __construct($cacheLifetime)
29
    {
30
        $this->cacheLifetime = $cacheLifetime;
31
    }
32
33
    /**
34
     * @param AbstractQuery $query
35
     */
36
    public function modify(AbstractQuery $query)
37
    {
38
        $query->setResultCacheLifetime($this->cacheLifetime);
39
    }
40
}
41