Passed
Push — master ( acf3f9...98cfe3 )
by Derek Stephen
03:04
created

HasDomTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setDom() 0 4 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
 * User: delboy1978uk
4
 * Date: 27/12/2016
5
 * Time: 00:27
6
 */
7
8
namespace Del\Form\Traits;
9
10
use DOMDocument;
11
use DOMElement;
12
use DOMText;
13
14
trait HasDomTrait
15
{
16
    /** @var DOMDocument $dom  */
17
    private $dom;
18
19
    /**
20
     * @param $tagType
21
     * @return DOMElement
22
     */
23 34
    public function createElement($tagType)
24
    {
25 34
        return $this->dom->createElement($tagType);
26
    }
27
28
    /**
29
     * @param $text
30
     * @return DOMText
31
     */
32 25
    public function createText($text)
33
    {
34 25
        return new DOMText($text);
35
    }
36
37
    /**
38
     * @return DOMElement
39
     */
40 3
    public function createLineBreak()
41
    {
42 3
        return $this->createElement('br');
43
    }
44
45
    /**
46
     * @return DOMDocument
47
     */
48 66
    public function getDom()
49
    {
50 66
        return $this->dom;
51
    }
52
53
    /**
54
     * @param DOMDocument $dom
55
     * @return $this
56
     */
57 66
    public function setDom($dom)
58
    {
59 66
        $this->dom = $dom;
60 66
        return $this;
61
    }
62
}