Completed
Push — master ( ecb243...bb1b22 )
by Pablo
03:58
created

MultiPolygon::getScalarValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpValueObjects\Spatial;
6
7
class MultiPolygon
8
{
9
    private $value;
10 6
    public function __construct(array $value)
11
    {
12 6
        $this->guard($value);
13 3
    }
14
15 3
    public function value(): array
16
    {
17 3
        return $this->value;
18
    }
19
20 6
    protected function guard(array $value): void
21
    {
22 6
        $values = [];
23
24 6
        foreach ($value as $item) {
25 6
            $values[] = new Polygon($item);
26
        }
27
28 3
        $this->value = $this->getScalarValues($values);
29 3
    }
30
31
    /**
32
     * @param Polygon[] $values
33
     * @return array
34
     */
35 3
    private function getScalarValues(array $values): array
36
    {
37 3
        $scalar = [];
38
39 3
        foreach ($values as $value) {
40 3
            $scalar[] = $value->value();
41
        }
42
43 3
        return $scalar;
44
    }
45
}
46