Completed
Push — master ( 0885cd...ef8e35 )
by Antoine
02:22
created

MultiPolygon   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 60
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getGeometryType() 0 4 1
A pointInPolygon() 0 11 3
A pointOnBoundary() 0 11 3
A pointOnVertex() 0 11 3
1
<?php
2
3
namespace League\Geotools\Polygon;
4
5
use League\Geotools\Coordinate\CoordinateInterface;
6
use League\Geotools\GeometryCollection;
7
8
class MultiPolygon extends GeometryCollection implements PolygonInterface
9
{
10
    const TYPE = 'MULTIPOLYGON';
11
12
    /**
13
     * @return string
14
     */
15 1
    public function getGeometryType()
16
    {
17 1
        return self::TYPE;
18
    }
19
20
    /**
21
     * @param  CoordinateInterface $coordinate
22
     * @return boolean
23
     */
24 2
    public function pointInPolygon(CoordinateInterface $coordinate)
25
    {
26
        /** @var PolygonInterface $polygon */
27 2
        foreach ($this->elements as $polygon) {
28 2
            if ($polygon->pointInPolygon($coordinate)) {
29 1
                return true;
30
            }
31 1
        }
32
33 1
        return false;
34
    }
35
36
    /**
37
     * @param  CoordinateInterface $coordinate
38
     * @return boolean
39
     */
40 2
    public function pointOnBoundary(CoordinateInterface $coordinate)
41
    {
42
        /** @var PolygonInterface $polygon */
43 2
        foreach ($this->elements as $polygon) {
44 2
            if ($polygon->pointOnBoundary($coordinate)) {
45 1
                return true;
46
            }
47 1
        }
48
49 1
        return false;
50
    }
51
52
    /**
53
     * @param  CoordinateInterface $coordinate
54
     * @return boolean
55
     */
56 2
    public function pointOnVertex(CoordinateInterface $coordinate)
57
    {
58
        /** @var PolygonInterface $polygon */
59 2
        foreach ($this->elements as $polygon) {
60 2
            if ($polygon->pointOnVertex($coordinate)) {
61 1
                return true;
62
            }
63 1
        }
64
65 1
        return false;
66
    }
67
}
68