CacheFacade::getCachePool()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Cache\Facade;
15
16
use Micro\Plugin\Cache\Business\Pool\CachePoolFactoryInterface;
17
use Micro\Plugin\Cache\Business\Pool\CachePoolInterface;
18
use Psr\Cache\CacheItemPoolInterface;
19
use Symfony\Component\Cache\Adapter\AbstractAdapter;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Cache\Adapter\AbstractAdapter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
class CacheFacade implements CacheFacadeInterface
22
{
23
    private CachePoolInterface|null $cachePool;
24
25 5
    public function __construct(
26
        private readonly CachePoolFactoryInterface $cachePoolFactory
27
    ) {
28 5
        $this->cachePool = null;
29
    }
30
31 4
    public function getCachePsr6(string $cachePoolName): CacheItemPoolInterface
32
    {
33 4
        return $this->getCachePool()->getCachePsr6($cachePoolName);
34
    }
35
36 5
    public function getCachePsr16(string $cachePoolName): CacheItemPoolInterface
37
    {
38 5
        return $this->getCachePool()->getCachePsr16($cachePoolName);
39
    }
40
41 4
    public function getCacheSymfony(string $cachePoolName): AbstractAdapter
42
    {
43 4
        return $this->getCachePool()->getCacheSymfony($cachePoolName);
44
    }
45
46 5
    protected function getCachePool(): CachePoolInterface
47
    {
48 5
        if ($this->cachePool) {
49 5
            return $this->cachePool;
50
        }
51
52 5
        $this->cachePool = $this->cachePoolFactory->create();
53
54 5
        return $this->cachePool;
55
    }
56
}
57