DefaultElementContent::addChild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace hemio\html\Trait_;
4
5
/**
6
 * Default implementation of {@link MaintainsChilds}.
7
 * Accepts every {@link HtmlCode} as child (so basically everything)
8
 *
9
 * @uses MaintainsChilds DefaultElementContent implements defaults for
10
 * more element specific methods (e.g. <code>isValidChild()</code>) required by MaintainsChilds
11
 * @author Michael Herold <[email protected]>
12
 */
13
trait DefaultElementContent
14
{
15
16
    /**
17
     * Used by addChild, therefore has to be defined here
18
     */
19
    abstract public function addChildInternal(\hemio\html\Interface_\HtmlCode $child);
20
21
    /**
22
     * This is not implemented in (@link ElementContent) since some elements
23
     * may only allow a restricted set of elements to be added as childs. This
24
     * is implemented via type hinting as feature for the API user.
25
     *
26
     * @param \hemio\html\Interface_\HtmlCode $child
27
     * @return \hemio\html\Interface_\HtmlCode
28
     */
29
    public function addChild(\hemio\html\Interface_\HtmlCode $child)
30
    {
31
        $this->addChildInternal($child);
32
        return $child;
33
    }
34
35
    /**
36
     * Returns always true
37
     *
38
     * @param \hemio\html\Interface_\HtmlCode $child
39
     * @return boolean
40
     */
41
    public function isValidChild(\hemio\html\Interface_\HtmlCode $child)
0 ignored issues
show
Unused Code introduced by
The parameter $child is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        return true;
44
    }
45
}
46