HasDomTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 7
c 1
b 0
f 1
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setDom() 0 3 1
A createLineBreak() 0 3 1
A createText() 0 3 1
A getDom() 0 3 1
A createElement() 0 3 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