Passed
Push — master ( 1efd90...6b1ebf )
by Melech
03:59
created

NullCache::forever()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[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 Valkyrja\Cache;
15
16
use Valkyrja\Cache\Contract\Cache as Contract;
17
use Valkyrja\Cache\Tagger\Contract\Tagger;
18
use Valkyrja\Cache\Tagger\Tagger as TagClass;
19
20
/**
21
 * Class NullCache.
22
 *
23
 * @author Melech Mizrachi
24
 */
25
class NullCache implements Contract
26
{
27
    /**
28
     * NullCache constructor.
29
     */
30
    public function __construct(
31
        protected string $prefix = ''
32
    ) {
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public function has(string $key): bool
39
    {
40
        return true;
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    public function get(string $key): string|null
47
    {
48
        return '';
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54
    public function many(string ...$keys): array
55
    {
56
        return [];
57
    }
58
59
    /**
60
     * @inheritDoc
61
     */
62
    public function put(string $key, string $value, int $minutes): void
63
    {
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69
    public function putMany(array $values, int $minutes): void
70
    {
71
    }
72
73
    /**
74
     * @inheritDoc
75
     */
76
    public function increment(string $key, int $value = 1): int
77
    {
78
        return $value;
79
    }
80
81
    /**
82
     * @inheritDoc
83
     */
84
    public function decrement(string $key, int $value = 1): int
85
    {
86
        return $value;
87
    }
88
89
    /**
90
     * @inheritDoc
91
     */
92
    public function forever(string $key, string $value): void
93
    {
94
    }
95
96
    /**
97
     * @inheritDoc
98
     */
99
    public function forget(string $key): bool
100
    {
101
        return true;
102
    }
103
104
    /**
105
     * @inheritDoc
106
     */
107
    public function flush(): bool
108
    {
109
        return true;
110
    }
111
112
    /**
113
     * @inheritDoc
114
     */
115
    public function getPrefix(): string
116
    {
117
        return $this->prefix;
118
    }
119
120
    /**
121
     * @inheritDoc
122
     */
123
    public function getTagger(string ...$tags): Tagger
124
    {
125
        return TagClass::make($this, ...$tags);
126
    }
127
128
    /**
129
     * Get key.
130
     *
131
     * @param string $key
132
     *
133
     * @return string
134
     */
135
    protected function getKey(string $key): string
136
    {
137
        return $this->getPrefix() . $key;
138
    }
139
}
140