TestPsrSimpleCache   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A delete() 0 4 1
A clear() 0 4 1
A setMultiple() 0 4 1
A deleteMultiple() 0 4 1
A getMultiple() 0 4 1
A get() 0 3 1
A set() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gember\CachePsr\Test\TestDoubles;
6
7
use Psr\SimpleCache\CacheInterface;
8
use DateInterval;
9
10
final class TestPsrSimpleCache implements CacheInterface
11
{
12
    /**
13
     * @var array<string, array{mixed, int|DateInterval|null}>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, array{mixe...int|DateInterval|null}> at position 6 could not be parsed: Expected ':' at position 6, but found 'mixed'.
Loading history...
14
     */
15
    public array $data = [];
16
17
    public function get(string $key, mixed $default = null): mixed
18
    {
19
        return $this->data[$key][0] ?? null;
20
    }
21
22
    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
23
    {
24
        $this->data[$key] = [$value, $ttl];
25
26
        return true;
27
    }
28
29
    public function delete(string $key): bool
30
    {
31
        // n/a
32
        return true;
33
    }
34
35
    public function clear(): bool
36
    {
37
        // n/a
38
        return true;
39
    }
40
41
    public function getMultiple(iterable $keys, mixed $default = null): iterable
42
    {
43
        // n/a
44
        return [];
45
    }
46
47
    /**
48
     * @param iterable<mixed> $values
49
     */
50
    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
51
    {
52
        // n/a
53
        return true;
54
    }
55
56
    public function deleteMultiple(iterable $keys): bool
57
    {
58
        // n/a
59
        return true;
60
    }
61
62
    public function has(string $key): bool
63
    {
64
        return isset($this->data[$key]);
65
    }
66
}
67