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

Polygon::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 2
b 0
f 2
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