Passed
Push — master ( 51a94b...0f3d7a )
by Jesús
01:31 queued 13s
created

ProfiledCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 5
eloc 10
c 0
b 0
f 0
dl 0
loc 33
rs 10
ccs 10
cts 12
cp 0.8333

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A put() 0 5 1
A has() 0 3 1
A get() 0 3 1
A getAll() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\Cache;
6
7
use Gacela\Framework\ClassResolver\Profiler\FileProfilerInterface;
8
9
final class ProfiledCache implements CacheInterface
10
{
11
    private CacheInterface $decoratedCache;
12
    private FileProfilerInterface $fileProfiler;
13
14 1
    public function __construct(
15
        CacheInterface $decoratedCache,
16
        FileProfilerInterface $fileProfiler
17
    ) {
18 1
        $this->decoratedCache = $decoratedCache;
19 1
        $this->fileProfiler = $fileProfiler;
20
    }
21
22 1
    public function has(string $cacheKey): bool
23
    {
24 1
        return $this->decoratedCache->has($cacheKey);
25
    }
26
27 1
    public function get(string $cacheKey): string
28
    {
29 1
        return $this->decoratedCache->get($cacheKey);
30
    }
31
32
    public function getAll(): array
33
    {
34
        return $this->decoratedCache->getAll();
35
    }
36
37 1
    public function put(string $cacheKey, string $className): void
38
    {
39 1
        $this->decoratedCache->put($cacheKey, $className);
40
41 1
        $this->fileProfiler->updateProfiler($this->decoratedCache->getAll());
42
    }
43
}
44