Completed
Pull Request — master (#5)
by Dmitriy
05:16
created

PathResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
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 9
    public function __construct(string $originalPath, FormatterInterface $formatter = null)
23
    {
24 9
        $this->originalPath = trim($originalPath);
25 9
        $this->formatter = $formatter;
26 9
    }
27
28 21
    public function resolvePathToEnvFile(HostId $hostId): string
29
    {
30 21
        return $this->formatter !== null ? $this->formatter->formatName($this->originalPath, $hostId) : $this->originalPath;
31
    }
32
}
33