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

MapTransformer::getSymbolByBiom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 3
cts 3
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 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