ItemList::addItem()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 3
crap 2
1
<?php
2
3
namespace CarlosIO\Geckoboard\Widgets;
4
5
use CarlosIO\Geckoboard\Data\ItemList\Label;
6
use CarlosIO\Geckoboard\Data\ItemList\Title;
7
8
/**
9
 * Class ItemList.
10
 */
11
class ItemList extends Widget
12
{
13
    protected $items = array();
14
15 3
    public function addItem(Title $title, $label, $description)
16
    {
17 3
        $count = count($this->items);
18 3
        $this->items[$count]['title'] = $title->toArray();
19
20 3
        if ($label instanceof Label) {
21 2
            $this->items[$count]['label'] = $label->toArray();
22 2
        }
23
24 3
        $this->items[$count]['description'] = $description;
25 3
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 4
    public function getData()
31
    {
32 4
        return $this->items;
33
    }
34
}
35