Completed
Pull Request — master (#7)
by Agaletskiy
05:00
created

HostIdMapper::getCurrentHost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\MultiEnv\HostDetector;
6
7
use Lamoda\MultiEnv\Model\HostId;
8
9
final class HostIdMapper implements HostDetectorInterface
10
{
11
    /**
12
     * @var HostDetectorInterface
13
     */
14
    private $inner;
15
    /**
16
     * @var array
17
     */
18
    private $hostIdMap;
19
20 3
    public function __construct(HostDetectorInterface $inner, array $hostIdMap = [])
21
    {
22 3
        $this->inner = $inner;
23 3
        $this->hostIdMap = $hostIdMap;
24 3
    }
25
26 3
    public function getCurrentHost(): HostId
27
    {
28 3
        $innerHostId = $this->inner->getCurrentHost();
29 3
        $value = $this->hostIdMap[(string)$innerHostId] ?? '';
30
31 3
        return new HostId($value);
32
    }
33
}