Passed
Push — feature/change-cache-to-profil... ( 160b60 )
by Chema
04:07
created

ProfiledInMemoryCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 10
c 1
b 0
f 0
dl 0
loc 32
rs 10
ccs 10
cts 12
cp 0.8333

5 Methods

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