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

BiomQualifier   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 22
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B qualifyBiom() 0 18 5
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