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

HostIdMapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 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
}