Passed
Push — master ( d1927b...0cf6ab )
by Herberto
02:26
created

NullCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 35
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 4 1
A contains() 0 4 1
A save() 0 4 1
A delete() 0 4 1
A getStats() 0 11 1
1
<?php
2
3
namespace Hgraca\Cache\Null;
4
5
use Hgraca\Cache\CacheInterface;
6
use Hgraca\Cache\Exception\CacheItemNotFoundException;
7
8
final class NullCache implements CacheInterface
9
{
10
11
    public function fetch(string $id)
12
    {
13
        throw new CacheItemNotFoundException();
14
    }
15
16
    public function contains(string $id): bool
17
    {
18
        return false;
19
    }
20
21
    public function save(string $id, $data, int $lifeTime = 0): bool
22
    {
23
        return false;
24
    }
25
26
    public function delete(string $id): bool
27
    {
28
        return true;
29
    }
30
31
    public function getStats(): array
32
    {
33
        return [
34
            static::STATS_HITS => 0,
35
            static::STATS_MISSES => 0,
36
            static::STATS_UPTIME => 0,
37
            static::STATS_MEMORY_USAGE => memory_get_usage(),
38
            static::STATS_MEMORY_AVAILABLE => ini_get('memory_limit') - memory_get_usage(),
39
            static::STATS_ITEM_COUNT => 0,
40
        ];
41
    }
42
}
43