Passed
Push — master ( dd634a...4d5ddd )
by Petr
02:10
created

BiomQualifier::qualifyBiom()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.0342

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 8
cts 9
cp 0.8889
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 6
nop 1
crap 5.0342
1
<?php
2
3
namespace Vehsamrak\Terraformator\LocationGenerator;
4
5
use Vehsamrak\Terraformator\Entity\Location;
6
use Vehsamrak\Terraformator\Entity\Map;
7
use Vehsamrak\Terraformator\Enum\Biom;
8
use Vehsamrak\Terraformator\Exception\UnimplementedException;
9
10
/**
11
 * @author Vehsamrak
12
 */
13
class BiomQualifier
14
{
15
16 2
    public function qualifyBiom(Map $map): Biom
17
    {
18 2
        $locationsAreSame = true;
19
20 2
        $firstBiom = $map->first()->getBiom();
21
        /** @var Location $location */
22 2
        foreach ($map->toArray() as $location) {
23 2
            if (!$location->getBiom()->equals($firstBiom)) {
24 2
            	$locationsAreSame = false;
25
            }
26
        }
27
28 2
        if ($map->count() == 8 && $locationsAreSame) {
29 2
        	return $firstBiom;
30
        }
31
32
        throw new UnimplementedException();
33
    }
34
}
35