EmptyTag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace RoyallTheFourth\HtmlDocument\Tag;
3
4
use RoyallTheFourth\HtmlDocument\Set\AttributeSet;
5
6
final class EmptyTag implements TagInterface
7
{
8
    private $attributes;
9
    private $name;
10
11
    public function __construct(string $name, AttributeSet $attributes = null)
12
    {
13
        $this->attributes = $attributes ?? new AttributeSet();
14
        $this->name = $name;
15
    }
16
17
    public function render(): string
18
    {
19
        $attributes = $this->attributes->render();
20
21
        return "<{$this->name}{$attributes}>\n";
22
    }
23
}
24