1 | <?php |
||
29 | abstract class AbstractElement extends AbstractNamed implements ElementInterface { |
||
30 | const DEPTH_INDENT = 2; |
||
31 | |||
32 | /** |
||
33 | * @var \Grafizzi\Graph\AttributeInterface[] |
||
34 | */ |
||
35 | public $fAttributes = array(); |
||
36 | |||
37 | /** |
||
38 | * @var \Grafizzi\Graph\AbstractElement[] $fChildren |
||
39 | */ |
||
40 | public $fChildren = array(); |
||
41 | |||
42 | /** |
||
43 | * The nesting level of the element. |
||
44 | * |
||
45 | * An unbound element, like the root graph, has depth 0. |
||
46 | * |
||
47 | * @var int |
||
48 | */ |
||
49 | public $fDepth = 0; |
||
50 | |||
51 | /** |
||
52 | * The parent element, when bound, or null otherwise. |
||
53 | * |
||
54 | * @var ElementInterface |
||
55 | */ |
||
56 | public $fParent = null; |
||
57 | |||
58 | /** |
||
59 | * Possibly not needed with an efficient garbage collector, but might help in |
||
60 | * case of dependency loops. |
||
61 | * |
||
62 | * XXX 20120512 check if really useful. |
||
63 | */ |
||
64 | 39 | public function __destruct() { |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 39 | public function addChild(ElementInterface $child) { |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | 39 | public function adjustDepth($extra = 0) { |
|
112 | |||
113 | /** |
||
114 | * Build the DOT string for this subtree. |
||
115 | * |
||
116 | * Ignores $directed. |
||
117 | * |
||
118 | * @see NamedInterface::build() |
||
119 | * |
||
120 | * @param bool $directed |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public function build($directed = null) { |
||
137 | |||
138 | /** |
||
139 | * @param array $attributes |
||
140 | * @param string $type |
||
141 | * @param string $name |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | 28 | protected function buildAttributes($attributes, $type, $name) { |
|
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | */ |
||
172 | public static function getAllowedChildTypes() { |
||
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | 1 | public function getAttributeByName($name) { |
|
184 | |||
185 | /** |
||
186 | * {@inheritdoc} |
||
187 | */ |
||
188 | 1 | public function getChildByName($name) { |
|
194 | |||
195 | /** |
||
196 | * {@inheritdoc} |
||
197 | */ |
||
198 | 1 | public function getParent() { |
|
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | */ |
||
205 | 1 | public function getRoot() { |
|
213 | |||
214 | /** |
||
215 | * {@inheritdoc} |
||
216 | */ |
||
217 | 4 | public function removeAttribute(AttributeInterface $attribute) { |
|
226 | |||
227 | /** |
||
228 | * {@inheritdoc} |
||
229 | */ |
||
230 | 4 | public function removeAttributeByName($name) { |
|
234 | |||
235 | /** |
||
236 | * {@inheritdoc} |
||
237 | */ |
||
238 | public function removeChild(ElementInterface $child) { |
||
248 | |||
249 | /** |
||
250 | * {@inheritdoc} |
||
251 | */ |
||
252 | public function removeChildByName($name) { |
||
265 | |||
266 | /** |
||
267 | * {@inheritdoc} |
||
268 | */ |
||
269 | 41 | public function setAttribute(AttributeInterface $attribute) { |
|
278 | |||
279 | /** |
||
280 | * {@inheritdoc} |
||
281 | */ |
||
282 | 50 | public function setAttributes(array $attributes) { |
|
292 | |||
293 | /** |
||
294 | * {@inheritdoc} |
||
295 | */ |
||
296 | 39 | public function setParent(ElementInterface $parent) { |
|
299 | |||
300 | } |
||
301 |