Passed
Push — master ( 3a646e...c8ba04 )
by Dmitriy
01:07 queued 19s
created

PathResolver::resolvePathToEnvFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
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