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

LinearRing::get()   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 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
namespace Ballen\Cartographer\Core;
3
4
use Ballen\Collection\Collection;
5
6
/**
7
 * Cartographer
8
 *
9
 * Cartographer is a PHP library providing the ability to programmatically
10
 * generate GeoJSON objects.
11
 *
12
 * @author Bobby Allen <[email protected]>
13
 * @license http://www.gnu.org/licenses/gpl-3.0.html
14
 * @link https://github.com/allebb/cartographer
15
 * @link http://bobbyallen.me
16
 *
17
 */
18
class LinearRing
19
{
20
21
    private $rings = [];
22
23
    /**
24
     * Add a coordinate group to the object.
25
     * @param array $coordinates
26
     * @return \Ballen\Cartographer\Core\LinearRing
27
     * @throws \InvalidArgumentException
28
     */
29 8
    public function addRing(array $coordinates)
30
    {
31
        //die(var_dump((count($coordinates) - 1)));
32 8
        if ($coordinates[0] != $coordinates[(count($coordinates) - 1)]) {
33
            throw new \InvalidArgumentException('The first and last coordinates must be the same.');
34
        }
35 8
        $this->rings[] = $coordinates;
36 8
        return $this;
37
    }
38
39
    /**
40
     * Returns the array of groups
41
     * @return array
42
     */
43 4
    public function get()
44
    {
45 4
        return $this->rings;
46
    }
47
}
48