Completed
Push — master ( f8b790...ca13fb )
by Bobby
03:19
created

Polygon::exportArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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