Passed
Push — master ( 0cf6ab...75e227 )
by Herberto
01:55
created

NullCache   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 46
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fetch() 0 5 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 DateTime;
6
use Hgraca\Cache\CacheInterface;
7
use Hgraca\Cache\Exception\CacheItemNotFoundException;
8
9
final class NullCache implements CacheInterface
10
{
11
    /** @var DateTime */
12
    private $creationTime;
13
14
    /** @var int */
15
    private $misses;
16
17 6
    public function __construct()
18
    {
19 6
        $this->creationTime = new DateTime();
20 6
    }
21
22 1
    public function fetch(string $id)
23
    {
24 1
        $this->misses++;
25 1
        throw new CacheItemNotFoundException();
26
    }
27
28 2
    public function contains(string $id): bool
29
    {
30 2
        return false;
31
    }
32
33 4
    public function save(string $id, $data, int $lifeTime = 0): bool
34
    {
35 4
        return false;
36
    }
37
38 1
    public function delete(string $id): bool
39
    {
40 1
        return true;
41
    }
42
43 4
    public function getStats(): array
44
    {
45
        return [
46 4
            static::STATS_HITS => 0,
47 4
            static::STATS_MISSES => $this->misses,
48 4
            static::STATS_UPTIME => $this->creationTime->getTimestamp(),
49 4
            static::STATS_MEMORY_USAGE => memory_get_usage(),
50 4
            static::STATS_MEMORY_AVAILABLE => ini_get('memory_limit') - memory_get_usage(),
51 4
            static::STATS_ITEM_COUNT => 0,
52
        ];
53
    }
54
}
55