Lists::addEntryWith()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
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