Lists   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 24.62 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 7
Bugs 3 Features 0
Metric Value
wmc 5
c 7
b 3
f 0
lcom 1
cbo 3
dl 16
loc 65
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addChild() 0 5 1
A addEntryWith() 0 6 1
A addSubUl() 8 8 1
A addSubOl() 8 8 1
A isValidChild() 0 4 1
addChildInternal() 0 1 ?

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 hemio\html\Trait_;
4
5
trait Lists
6
{
7
8
    /**
9
     *
10
     * @param \hemio\html\Li $child
11
     * @return \hemio\html\Li
12
     */
13
    public function addChild(\hemio\html\Li $child)
14
    {
15
        $this->addChildInternal($child);
16
        return $child;
17
    }
18
19
    /**
20
     * Adds <<li>> tag containing a given entry
21
     *
22
     * @param \hemio\html\Interface_\HtmlCode $withEntry The contained entry
23
     * @return \hemio\html\Li
24
     */
25
    public function addEntryWith(\hemio\html\Interface_\HtmlCode $withEntry)
26
    {
27
        $li = new \hemio\html\Li();
28
        $li->addChild($withEntry);
29
        return $this->addChild($li);
30
    }
31
32
    /**
33
     *
34
     * @param \hemio\html\Interface_\HtmlCode $header
35
     * @return \hemio\html\Ul
36
     */
37 View Code Duplication
    public function addSubUl(\hemio\html\Interface_\HtmlCode $header)
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...
38
    {
39
        $li      = $this->addChild(new \hemio\html\Li);
40
        $li->addChild($header);
41
        $newList = new \hemio\html\Ul();
42
        $li->addChild($newList);
43
        return $newList;
44
    }
45
46
    /**
47
     *
48
     * @param \hemio\html\Interface_\HtmlCode $header
49
     * @return \hemio\html\Ol
50
     */
51 View Code Duplication
    public function addSubOl(\hemio\html\Interface_\HtmlCode $header)
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...
52
    {
53
        $li      = $this->addChild(new \hemio\html\Li);
54
        $li->addChild($header);
55
        $newList = new \hemio\html\Ol();
56
        $li->addChild($newList);
57
        return $newList;
58
    }
59
60
    public function isValidChild(\hemio\html\Interface_\HtmlCode $child)
61
    {
62
        return $child instanceof \hemio\html\Li;
63
    }
64
65
    /**
66
     * Used by addChild, therefore has to be defined here
67
     */
68
    abstract public function addChildInternal(\hemio\html\Interface_\HtmlCode $child);
69
}
70