NullCache::decrement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
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 Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Valkyrja\Cache\Contract\Cache as Contract;
18
use Valkyrja\Cache\Tagger\Contract\Tagger;
19
use Valkyrja\Cache\Tagger\Tagger as TagClass;
20
21
/**
22
 * Class NullCache.
23
 *
24
 * @author Melech Mizrachi
25
 */
26
class NullCache implements Contract
27
{
28
    /**
29
     * NullCache constructor.
30
     */
31
    public function __construct(
32
        protected string $prefix = ''
33
    ) {
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    #[Override]
40
    public function has(string $key): bool
41
    {
42
        return true;
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    #[Override]
49
    public function get(string $key): string|null
50
    {
51
        return '';
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57
    #[Override]
58
    public function many(string ...$keys): array
59
    {
60
        return [];
61
    }
62
63
    /**
64
     * @inheritDoc
65
     */
66
    #[Override]
67
    public function put(string $key, string $value, int $minutes): void
68
    {
69
    }
70
71
    /**
72
     * @inheritDoc
73
     */
74
    #[Override]
75
    public function putMany(array $values, int $minutes): void
76
    {
77
    }
78
79
    /**
80
     * @inheritDoc
81
     */
82
    #[Override]
83
    public function increment(string $key, int $value = 1): int
84
    {
85
        return $value;
86
    }
87
88
    /**
89
     * @inheritDoc
90
     */
91
    #[Override]
92
    public function decrement(string $key, int $value = 1): int
93
    {
94
        return $value;
95
    }
96
97
    /**
98
     * @inheritDoc
99
     */
100
    #[Override]
101
    public function forever(string $key, string $value): void
102
    {
103
    }
104
105
    /**
106
     * @inheritDoc
107
     */
108
    #[Override]
109
    public function forget(string $key): bool
110
    {
111
        return true;
112
    }
113
114
    /**
115
     * @inheritDoc
116
     */
117
    #[Override]
118
    public function flush(): bool
119
    {
120
        return true;
121
    }
122
123
    /**
124
     * @inheritDoc
125
     */
126
    #[Override]
127
    public function getPrefix(): string
128
    {
129
        return $this->prefix;
130
    }
131
132
    /**
133
     * @inheritDoc
134
     */
135
    #[Override]
136
    public function getTagger(string ...$tags): Tagger
137
    {
138
        return TagClass::make($this, ...$tags);
139
    }
140
141
    /**
142
     * Get key.
143
     *
144
     * @param string $key
145
     *
146
     * @return string
147
     */
148
    protected function getKey(string $key): string
149
    {
150
        return $this->getPrefix() . $key;
151
    }
152
}
153