HasDomTrait::createElement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Form\Traits;
6
7
use DOMDocument;
8
use DOMElement;
9
use DOMText;
10
11
trait HasDomTrait
12
{
13
    private DOMDocument $dom;
14
15 34
    public function createElement(string $tagType): DOMElement
16
    {
17 34
        return $this->dom->createElement($tagType);
18
    }
19
20 25
    public function createText($text): DOMText
21
    {
22 25
        return new DOMText($text ?? '');
23
    }
24
25 3
    public function createLineBreak(): DOMElement
26
    {
27 3
        return $this->createElement('br');
28
    }
29
30 67
    public function getDom(): DOMDocument
31
    {
32 67
        return $this->dom;
33
    }
34
35 67
    public function setDom($dom): void
36
    {
37 67
        $this->dom = $dom;
38
    }
39
}
40