Funnel::getData()   B
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 4

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 23
ccs 16
cts 16
cp 1
rs 8.7972
cc 4
eloc 13
nc 8
nop 0
crap 4
1
<?php
2
3
namespace CarlosIO\Geckoboard\Widgets;
4
5
/**
6
 * Class Funnel.
7
 */
8
class Funnel extends Widget
9
{
10
    protected $type = false;
11
    protected $showPercentage = true;
12
    protected $dataset = array();
13
14 1
    public function setShowPercentage($showPercentage)
15
    {
16 1
        $this->showPercentage = $showPercentage;
17
18 1
        return $this;
19
    }
20
21 1
    public function getShowPercentage()
22
    {
23 1
        return $this->showPercentage;
24
    }
25
26 1
    public function setType($type)
27
    {
28 1
        $this->type = $type;
29
30 1
        return $this;
31
    }
32
33 1
    public function getType()
34
    {
35 1
        return $this->type;
36
    }
37
38 1
    public function addEntry($entry)
39
    {
40 1
        $this->dataset[] = $entry;
41
42 1
        return $this;
43
    }
44
45 1
    public function getData()
46
    {
47 1
        $data = array();
48 1
        foreach ($this->dataset as $entry) {
49 1
            $data[] = $entry->toArray();
50 1
        }
51
52 1
        $result = array();
53
54 1
        $type = $this->getType();
55 1
        if ($type) {
56 1
            $result['type'] = 'reverse';
57 1
        }
58
59 1
        $show = $this->getShowPercentage();
60 1
        if (!$show) {
61 1
            $result['percentage'] = 'hide';
62 1
        }
63
64 1
        $result['item'] = $data;
65
66 1
        return $result;
67
    }
68
}
69