Passed
Push — master ( ab9dd5...179053 )
by Petr
05:44
created

SurroundingMap::add()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Vehsamrak\Terraformator\Entity;
4
5
use Vehsamrak\Terraformator\Exception\TooManyLocationsException;
6
7
/**
8
 * Map with 8 or less locations to represend surroundings of central location (3x3 location square)
9
 * @author Vehsamrak
10
 */
11
class SurroundingMap extends Map
12
{
13
14
    /** {@inheritDoc} */
15 3
    public function add($element): bool
16
    {
17 3
        if ($this->count() < 8) {
18 2
            return parent::add($element);
19
        } else {
20 1
            throw new TooManyLocationsException();
21
        }
22
    }
23
}
24
25