PathResolverCacheDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A resolve() 0 7 2
1
<?php
2
3
/*
4
 *  This file is part of the Micro framework package.
5
 *
6
 *  (c) Stanislau Komar <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace Micro\Plugin\Configuration\Helper\Business\Path;
13
14
class PathResolverCacheDecorator implements PathResolverInterface
15
{
16
    /**
17
     * @var array<string, string>
18
     */
19
    private array $cache;
20
21 2
    public function __construct(private readonly PathResolverInterface $pathResolver)
22
    {
23 2
        $this->cache = [];
24
    }
25
26 2
    public function resolve(string $relative): string
27
    {
28 2
        if (!\array_key_exists($relative, $this->cache)) {
29 2
            $this->cache[$relative] = $this->pathResolver->resolve($relative);
30
        }
31
32 2
        return $this->cache[$relative];
33
    }
34
}
35