Test Setup Failed
Branch 0.x (13f0ad)
by Pavel
13:06 queued 01:31
created

NullCacher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A invalidate() 0 3 1
A save() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[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
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AppBundle\Cache\Cacher;
17
18
use Veslo\AppBundle\Cache\CacherInterface;
19
20
/**
21
 * Null cacher is a dummy object for cases when a real cacher is not needed
22
 * Eliminates an extra boilerplate checks in client code
23
 *
24
 * @see Nice pattern description here: https://github.com/domnikl/DesignPatternsPHP/tree/master/Behavioral/NullObject
25
 */
26
class NullCacher implements CacherInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function save($value): bool
32
    {
33
        return true;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function get()
40
    {
41
        return null;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function invalidate(): bool
48
    {
49
        return true;
50
    }
51
}
52