Entry   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 104
Duplicated Lines 20.19 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 11
c 2
b 1
f 1
lcom 1
cbo 0
dl 21
loc 104
ccs 34
cts 34
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setValue() 0 6 1
A setLabel() 0 6 1
A getLabel() 0 4 1
A getValue() 0 4 1
A getColor() 0 4 1
A setColor() 0 4 1
A toArray() 21 21 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace CarlosIO\Geckoboard\Data\PieChart;
4
5
/**
6
 * Class Entry.
7
 */
8
class Entry
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $value;
14
15
    /**
16
     * @var string
17
     */
18
    protected $color = null;
19
20
    /**
21
     * @var string
22
     */
23
    protected $label;
24
25 1
    public function __construct()
26
    {
27 1
        $this->value = null;
28 1
        $this->label = null;
29 1
    }
30
31
    /**
32
     * @param $value
33
     *
34
     * @return $this
35
     */
36 1
    public function setValue($value)
37
    {
38 1
        $this->value = $value;
39
40 1
        return $this;
41
    }
42
43
    /**
44
     * @param  $label
45
     *
46
     * @return $this
47
     */
48 1
    public function setLabel($label)
49
    {
50 1
        $this->label = $label;
51
52 1
        return $this;
53
    }
54
55
    /**
56
     * @return string
57
     */
58 1
    public function getLabel()
59
    {
60 1
        return $this->label;
61
    }
62
63
    /**
64
     * @return string
65
     */
66 1
    public function getValue()
67
    {
68 1
        return $this->value;
69
    }
70
71
    /**
72
     * @return string
73
     */
74 1
    public function getColor()
75
    {
76 1
        return $this->color;
77
    }
78
79
    /**
80
     * @param string $color
81
     */
82 1
    public function setColor($color)
83
    {
84 1
        $this->color = $color;
85 1
    }
86
87
    /**
88
     * @return array
89
     */
90 1 View Code Duplication
    public function toArray()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
    {
92 1
        $result = array();
93
94 1
        $value = $this->getValue();
95 1
        if (null !== $value) {
96 1
            $result['value'] = (string) $value;
97 1
        }
98
99 1
        $label = $this->getLabel();
100 1
        if (null !== $label) {
101 1
            $result['label'] = $label;
102 1
        }
103
104 1
        $color = $this->getColor();
105 1
        if (null !== $color) {
106 1
            $result['color'] = $color;
107 1
        }
108
109 1
        return $result;
110
    }
111
}
112