89% of 219OPs |
88% of 41Lines |
87% of 38Branches |
92% of 26Paths |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\template; |
4 |
|
5 |
use |
6 |
mageekguy\atoum |
7 |
; |
8 |
|
9 |
class data |
10 |
{ |
11 |
protected $parent = null; |
12 |
protected $rank = null; |
13 |
protected $data = null; |
14 |
|
15 |
public function __construct($data = null)100% |
16 |
{ |
17 |
$this->setData($data); |
18 |
} |
19 |
|
20 |
public function __toString()100% |
21 |
{ |
22 |
return $this->getData(); |
23 |
} |
24 |
|
25 |
public function resetData()100% |
26 |
{ |
27 |
$this->data = null; |
28 |
|
29 |
return $this; |
30 |
} |
31 |
|
32 |
public function getData()100% |
33 |
{ |
34 |
return ($this->data === null ? '' : $this->data); |
35 |
} |
36 |
|
37 |
public function setData($data)100% |
38 |
{ |
39 |
return $this->resetData()->addData($data); |
40 |
} |
41 |
|
42 |
public function addData($data)100% |
43 |
{ |
44 |
$data = (string) $data; |
45 |
|
46 |
if ($data != '') |
47 |
{ |
48 |
$this->data .= $data; |
49 |
} |
50 |
|
51 |
return $this; |
52 |
} |
53 |
|
54 |
public function setParent(atoum\template $parent)100% |
55 |
{ |
56 |
$parent->addChild($this); |
57 |
|
58 |
return $this; |
59 |
} |
60 |
|
61 |
public function getParent()100% |
62 |
{ |
63 |
return $this->parent; |
64 |
} |
65 |
|
66 |
public function getRoot()100% |
67 |
{ |
68 |
$root = $this; |
69 |
|
70 |
while ($root->parent !== null) |
71 |
{ |
72 |
$root = $root->parent; |
73 |
} |
74 |
|
75 |
return $root; |
76 |
} |
77 |
|
78 |
public function isRoot()100% |
79 |
{ |
80 |
return ($this->parent === null); |
81 |
} |
82 |
|
83 |
public function parentIsSet()100% |
84 |
{ |
85 |
return ($this->parent !== null); |
86 |
} |
87 |
|
88 |
public function unsetParent()100% |
89 |
{ |
90 |
if ($this->parentIsSet() === true) |
91 |
{ |
92 |
$this->parent->deleteChild($this); |
93 |
} |
94 |
|
95 |
return $this; |
96 |
} |
97 |
|
98 |
public function build()100% |
99 |
{ |
100 |
return $this; |
101 |
} |
102 |
|
103 |
public function addToParent()0% |
104 |
{ |
105 |
if ($this->build()->parentIsSet() === true) |
106 |
{ |
107 |
$this->parent->addData($this); |
108 |
} |
109 |
|
110 |
return $this; |
111 |
} |
112 |
|
113 |
public function getTag()100% |
114 |
{ |
115 |
return null; |
116 |
} |
117 |
|
118 |
public function getId()100% |
119 |
{ |
120 |
return null; |
121 |
} |
122 |
|
123 |
public function getByTag($tag)100% |
124 |
{ |
125 |
return array(); |
126 |
} |
127 |
|
128 |
public function getById($id, $fromRoot = true)100% |
129 |
{ |
130 |
return null; |
131 |
} |
132 |
|
133 |
public function hasChildren()100% |
134 |
{ |
135 |
return false; |
136 |
} |
137 |
|
138 |
public function getChild($rank)100% |
139 |
{ |
140 |
return null; |
141 |
} |
142 |
|
143 |
public function getChildren()100% |
144 |
{ |
145 |
return array(); |
146 |
} |
147 |
} |