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

NullCache::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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