PathResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolvePathToEnvFile() 0 3 2
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\MultiEnv\FileReader\PathResolver;
6
7
use Lamoda\MultiEnv\Formatter\FormatterInterface;
8
use Lamoda\MultiEnv\Model\HostId;
9
10
final class PathResolver implements PathResolverInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    private $originalPath;
16
17
    /**
18
     * @var FormatterInterface|null
19
     */
20
    private $formatter;
21
22 10
    public function __construct(string $originalPath, FormatterInterface $formatter = null)
23
    {
24 10
        $this->originalPath = trim($originalPath);
25 10
        $this->formatter = $formatter;
26 10
    }
27
28 22
    public function resolvePathToEnvFile(HostId $hostId): string
29
    {
30 22
        return $this->formatter !== null ? $this->formatter->formatName($this->originalPath, $hostId) : $this->originalPath;
31
    }
32
}
33