Entry   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 96
Duplicated Lines 20.83 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 10
c 3
b 1
f 1
lcom 1
cbo 0
dl 20
loc 96
ccs 30
cts 30
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setPrefix() 0 6 1
A getPrefix() 0 4 1
A setText() 0 6 1
A getText() 0 4 1
A setValue() 0 6 1
A getValue() 0 4 1
A toArray() 20 20 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;
4
5
/**
6
 * Class Entry.
7
 */
8
class Entry
9
{
10
    /**
11
     * @var
12
     */
13
    protected $value = null;
14
    /**
15
     * @var
16
     */
17
    protected $text = null;
18
    /**
19
     * @var
20
     */
21
    protected $prefix = null;
22
23
    /**
24
     * @param $prefix
25
     *
26
     * @return $this
27
     */
28 2
    public function setPrefix($prefix)
29
    {
30 2
        $this->prefix = $prefix;
31
32 2
        return $this;
33
    }
34
35
    /**
36
     * @return mixed
37
     */
38 6
    public function getPrefix()
39
    {
40 6
        return $this->prefix;
41
    }
42
43
    /**
44
     * @param $text
45
     *
46
     * @return $this
47
     */
48 6
    public function setText($text)
49
    {
50 6
        $this->text = $text;
51
52 6
        return $this;
53
    }
54
55
    /**
56
     * @return mixed
57
     */
58 6
    public function getText()
59
    {
60 6
        return $this->text;
61
    }
62
63
    /**
64
     * @param $value
65
     *
66
     * @return $this
67
     */
68 6
    public function setValue($value)
69
    {
70 6
        $this->value = $value;
71
72 6
        return $this;
73
    }
74
75
    /**
76
     * @return mixed
77
     */
78 6
    public function getValue()
79
    {
80 6
        return $this->value;
81
    }
82
83 6 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...
84
    {
85 6
        $result = array();
86 6
        $text = $this->getText();
87 6
        if (null !== $text) {
88 6
            $result['text'] = $text;
89 6
        }
90
91 6
        $value = $this->getValue();
92 6
        if (null !== $value) {
93 6
            $result['value'] = $value;
94 6
        }
95
96 6
        $prefix = $this->getPrefix();
97 6
        if (null !== $prefix) {
98 2
            $result['prefix'] = $prefix;
99 2
        }
100
101 6
        return $result;
102
    }
103
}
104