Passed
Push — master ( 5a00cf...0692f7 )
by Petr
02:06
created

MapTransformer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertToString() 0 12 2
A getSymbolByBiom() 0 9 1
1
<?php
2
3
namespace Vehsamrak\Terraformator\Service;
4
5
use Vehsamrak\Terraformator\Entity\Location;
6
use Vehsamrak\Terraformator\Entity\Map;
7
use Vehsamrak\Terraformator\Enum\Biom;
8
9
/**
10
 * @author Vehsamrak
11
 */
12
class MapTransformer
13
{
14
15 3
    public function convertToString(Map $map): string
16
    {
17 3
        $stringMap = '';
18
19
        /** @var Location $location */
20 3
        foreach ($map->toArray() as $location) {
21 2
            $biom = $location->getBiom();
22 2
            $stringMap .= $this->getSymbolByBiom($biom);
23
        }
24
25 3
        return $stringMap;
26
    }
27
28 2
    private function getSymbolByBiom(Biom $biom): string
29
    {
30
        $biomSymbolMatrix = [
31 2
            Biom::FOREST => '^',
32
            Biom::FIELD  => '_',
33
        ];
34
35 2
        return $biomSymbolMatrix[$biom->getValue()];
36
    }
37
}
38