Map::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 2
Metric Value
c 2
b 1
f 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace CarlosIO\Geckoboard\Widgets;
4
5
use CarlosIO\Geckoboard\Data\Point;
6
7
/**
8
 * Class Map.
9
 */
10
class Map extends Widget
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $dataset;
16
17 3
    public function __construct()
18
    {
19 3
        $this->dataset = array();
20 3
    }
21
22
    /**
23
     * @return array
24
     */
25 1
    public function getPoints()
26
    {
27 1
        return $this->dataset;
28
    }
29
30
    /**
31
     * @param Point $point
32
     *
33
     * @return $this
34
     */
35 2
    public function addPoint(Point $point)
36
    {
37 2
        $this->dataset[] = $point;
38
39 2
        return $this;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 2
    public function getData()
46
    {
47 2
        $result = array();
48 2
        foreach ($this->dataset as $point) {
49 2
            $result[] = $point->toArray();
50 2
        }
51
52 2
        return array('points' => array('point' => $result));
53
    }
54
}
55