ElementNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Biurad opensource projects.
7
 *
8
 * PHP version 7.2 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2019 Biurad Group (https://biurad.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Biurad\UI\Html\Node;
19
20
class ElementNode extends SelfCloseNode
21
{
22
    /** @var string */
23
    public $html;
24
25
    /** @var array<int,ElementNode> */
26
    public $children = [];
27
28
    /**
29
     * @param array<int,AttributeNode> $attributes
30
     */
31 1
    public function __construct(string $name, string $html = '', array $attributes = [])
32
    {
33 1
        parent::__construct($name, $attributes);
34 1
        $this->html = $html;
35
    }
36
37 1
    public function __toString(): string
38
    {
39 1
        $attrHtml = '';
40
41 1
        foreach ($this->attributes as $attribute) {
42 1
            $attrHtml .= (string) $attribute;
43
        }
44
45 1
        return '<' . $this->name . $attrHtml . '>' . $this->html . '</' . $this->name . '>';
46
    }
47
}
48