Conditions | 6 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 6 | public function qualifyBiom(Map $map): Biom |
|
25 | { |
||
26 | 6 | $firstLocationInMap = $map->first(); |
|
27 | |||
28 | 6 | if (!$firstLocationInMap) { |
|
29 | 4 | return $this->getRandomBiom(); |
|
30 | } |
||
31 | |||
32 | 4 | $firstBiom = $firstLocationInMap->getBiom(); |
|
33 | 4 | $locationsAreSame = true; |
|
34 | |||
35 | /** @var Location $location */ |
||
36 | 4 | foreach ($map->toArray() as $location) { |
|
37 | 4 | if (!$location->getBiom()->equals($firstBiom)) { |
|
38 | 4 | $locationsAreSame = false; |
|
39 | } |
||
40 | } |
||
41 | |||
42 | 4 | if ($map->count() == 8 && $locationsAreSame) { |
|
43 | 2 | return $firstBiom; |
|
44 | } |
||
45 | |||
46 | 2 | return $this->getRandomBiom(); |
|
47 | } |
||
48 | |||
58 |