NullCache::clear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * NullCache convenience object taken from symfony/cache. Adapted for
7
 * PHP7.1 strict_types, original author Nicolas Grekas <[email protected]>.
8
 *
9
 * @see       https://github.com/soluble-io/soluble-mediatools for the canonical repository
10
 *
11
 * @copyright Copyright (c) 2018-2020 Sébastien Vanvelthem. (https://github.com/belgattitude)
12
 * @license   https://github.com/soluble-io/soluble-mediatools/blob/master/LICENSE.md MIT
13
 */
14
15
namespace Soluble\MediaTools\Common\Cache;
16
17
use Psr\SimpleCache\CacheInterface;
18
19
/**
20
 * NullCache convenience object taken from symfony/cache. Adapted for
21
 * PHP7.1 strict_types, original author Nicolas Grekas <[email protected]>.
22
 */
23
final class NullCache implements CacheInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     *
28
     * @return mixed
29
     */
30 13
    public function get($key, $default = null)
31
    {
32 13
        return $default;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     *
38
     * @return iterable
39
     */
40 1
    public function getMultiple($keys, $default = null)
41
    {
42 1
        foreach ($keys as $key) {
43 1
            yield $key => $default;
44
        }
45 1
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function has($key): bool
51
    {
52 1
        return false;
53
    }
54
55 1
    public function clear(): bool
56
    {
57 1
        return true;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function delete($key): bool
64
    {
65 1
        return true;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 1
    public function deleteMultiple($keys): bool
72
    {
73 1
        return true;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 11
    public function set($key, $value, $ttl = null): bool
80
    {
81 11
        return false;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87 1
    public function setMultiple($values, $ttl = null): bool
88
    {
89 1
        return false;
90
    }
91
}
92