Passed
Push — master ( e44489...51d43e )
by Bobby
09:09
created

Polygon   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 3
Metric Value
eloc 8
dl 0
loc 47
ccs 9
cts 9
cp 1
rs 10
c 4
b 1
f 3
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
A export() 0 4 1
A exportArray() 0 3 1
A __construct() 0 3 1
1
<?php
2
namespace Ballen\Cartographer;
3
4
use Ballen\Cartographer\Core\GeoJSONTypeInterface;
5
use Ballen\Cartographer\Core\Multipliable;
6
use Ballen\Cartographer\Core\GeoJSON;
7
use Ballen\Cartographer\Core\LinearRing;
8
9
/**
10
 * Cartographer
11
 *
12
 * Cartographer is a PHP library providing the ability to programmatically
13
 * generate GeoJSON objects.
14
 *
15
 * @author Bobby Allen <[email protected]>
16
 * @license http://www.gnu.org/licenses/gpl-3.0.html
17
 * @link https://github.com/allebb/cartographer
18
 * @link http://bobbyallen.me
19
 *
20
 */
21
class Polygon extends GeoJSON implements GeoJSONTypeInterface, Multipliable
22
{
23
24
    /**
25
     * The GeoJSON schema type
26
     * @var string
27
     */
28
    protected $type = GeoJSON::TYPE_POLYGON;
29
30
    /**
31
     * The LinearRing collection
32
     * @var LinearRing
33
     */
34
    private $polygon;
35
36 8
    public function __construct(LinearRing $polygon)
37
    {
38 8
        $this->polygon = $polygon;
39 8
    }
40
41
    /**
42
     * Exports the type specific schema element(s).
43
     * @return array
44
     */
45 2
    public function export()
46
    {
47
        return [
48 2
            'coordinates' => $this->polygon->get(),
49
        ];
50
    }
51
52
    /**
53
     * Export the polygon data as an array.
54
     * @return array
55
     */
56 2
    public function exportArray()
57
    {
58 2
        return $this->polygon->get();
59
    }
60
61
    /**
62
     * Validate the type specific schema element(s).
63
     * @return boolean
64
     */
65 2
    public function validate()
66
    {
67 2
        return true;
68
    }
69
}
70