HostIdMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentHost() 0 6 1
A __construct() 0 4 1
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 string[]
17
     */
18
    private $hostIdMap;
19
20
    /**
21
     * @param HostDetectorInterface $inner
22
     * @param string[] $hostIdMap
23
     */
24 3
    public function __construct(HostDetectorInterface $inner, array $hostIdMap = [])
25
    {
26 3
        $this->inner = $inner;
27 3
        $this->hostIdMap = $hostIdMap;
28 3
    }
29
30 3
    public function getCurrentHost(): HostId
31
    {
32 3
        $innerHostId = $this->inner->getCurrentHost();
33 3
        $value = $this->hostIdMap[(string)$innerHostId] ?? '';
34
35 3
        return new HostId($value);
36
    }
37
}