PathResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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