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

Polygon   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 4
Metric Value
wmc 4
c 5
b 1
f 4
lcom 1
cbo 2
dl 0
loc 49
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A export() 0 6 1
A exportArray() 0 4 1
A validate() 0 4 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