Item   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 7
c 4
b 1
f 1
lcom 1
cbo 0
dl 0
loc 80
ccs 21
cts 21
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setText() 0 6 1
A getText() 0 8 2
A setType() 0 6 1
A getType() 0 8 2
A toArray() 0 8 1
1
<?php
2
3
namespace CarlosIO\Geckoboard\Data\Text;
4
5
class Item
6
{
7
    const TYPE_NONE = 0;
8
    const TYPE_ALERT = 1;
9
    const TYPE_INFO = 2;
10
11
    /**
12
     * @var string
13
     */
14
    protected $text;
15
16
    /**
17
     * @var int
18
     */
19
    protected $type;
20
21
    /**
22
     * @param string $text
23
     *
24
     * @return $this
25
     */
26 3
    public function setText($text)
27
    {
28 3
        $this->text = $text;
29
30 3
        return $this;
31
    }
32
33
    /**
34
     * Returns text attribute.
35
     *
36
     * @return string
37
     */
38 3
    public function getText()
39
    {
40 3
        if (null === $this->text) {
41 1
            $this->text = '';
42 1
        }
43
44 3
        return $this->text;
45
    }
46
47
    /**
48
     * @param int $type Type of the item, can be 0, 1 or 2
49
     *
50
     * @return $this
51
     */
52 2
    public function setType($type)
53
    {
54 2
        $this->type = $type;
55
56 2
        return $this;
57
    }
58
59
    /**
60
     * @return int
61
     */
62 3
    public function getType()
63
    {
64 3
        if (null === $this->type) {
65 2
            $this->type = 0;
66 2
        }
67
68 3
        return $this->type;
69
    }
70
71
    /**
72
     * Returns an array representation of this object.
73
     *
74
     * @return array
75
     */
76 3
    public function toArray()
77
    {
78 3
        $result = array();
79 3
        $result['text'] = $this->getText();
80 3
        $result['type'] = $this->getType();
81
82 3
        return $result;
83
    }
84
}
85