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

LinearRing   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
dl 0
loc 28
ccs 6
cts 7
cp 0.8571
rs 10
c 1
b 0
f 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addRing() 0 8 2
A get() 0 3 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