AttributeNode   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 26.23 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 7
lcom 2
cbo 2
dl 16
loc 61
rs 10
c 2
b 2
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormattedName() 0 4 1
A getValue() 0 4 1
A setValue() 0 4 1
A previousSibling() 8 8 2
A nextSibling() 8 8 2

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 Saxulum\JsonDocument;
4
5
class AttributeNode extends AbstractNode
6
{
7
    /**
8
     * @var null|string|int|float|bool
9
     */
10
    protected $value;
11
12
    /**
13
     * @var ObjectNode
14
     */
15
    protected $parent;
16
17
    /**
18
     * @return string
19
     */
20
    public function getFormattedName()
21
    {
22
        return '@' . $this->name;
23
    }
24
25
    /**
26
     * @return bool|float|int|null|string
27
     */
28
    public function getValue()
29
    {
30
        return $this->value;
31
    }
32
33
    /**
34
     * @param  bool|float|int|null|string $value
35
     * @return $this
36
     */
37
    public function setValue($value)
38
    {
39
        $this->value = $value;
40
    }
41
42
    /**
43
     * @return null|AttributeNode
44
     */
45 View Code Duplication
    public function previousSibling()
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...
46
    {
47
        if (null === $parent = $this->parent) {
48
            return null;
49
        }
50
51
        return $this->getSibling($parent->getAttributes(), -1);
52
    }
53
54
    /**
55
     * @return null|AttributeNode
56
     */
57 View Code Duplication
    public function nextSibling()
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...
58
    {
59
        if (null === $parent = $this->parent) {
60
            return null;
61
        }
62
63
        return $this->getSibling($parent->getAttributes(), 1);
64
    }
65
}
66