Completed
Push — master ( a9adfd...b66e97 )
by Kevin
02:14
created

ClosedElement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 40 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 12
loc 30
ccs 0
cts 23
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getChildren() 0 4 1
A addChild() 0 4 1
A removeChild() 0 4 1
A toString() 12 12 3

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 Groundskeeper\Tokens\Elements;
4
5
class ClosedElement extends Element
6
{
7
    public function getChildren()
8
    {
9
        return array();
10
    }
11
12
    public function addChild(Token $token)
13
    {
14
        return $this;
15
    }
16
17
    public function removeChild(Token $token)
18
    {
19
        return true;
20
    }
21
22 View Code Duplication
    public function toString($prefix = '', $suffix = '')
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...
23
    {
24
        $output = $prefix . '<' . $this->name;
0 ignored issues
show
Bug introduced by
The property name cannot be accessed from this context as it is declared private in class Groundskeeper\Tokens\Elements\Element.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
25
        foreach ($this->attributes as $key => $value) {
0 ignored issues
show
Bug introduced by
The property attributes cannot be accessed from this context as it is declared private in class Groundskeeper\Tokens\Elements\Element.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
26
            $output .= ' ' . $key;
27
            if (is_string($value)) {
28
                $output .= '="' . $value . '"';
29
            }
30
        }
31
32
        return $output . '/>' . $suffix;
33
    }
34
}
35