Total Complexity | 13 |
Total Lines | 77 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | class XHtmlElement extends XHtmlSimpleElement |
||
19 | { |
||
20 | public $_text; |
||
21 | |||
22 | public $_htmlcode = ''; |
||
23 | |||
24 | public $_siblings = []; |
||
25 | |||
26 | public function __construct($text = null) |
||
27 | { |
||
28 | parent::__construct(); |
||
29 | |||
30 | if ($text) { |
||
31 | $this->set_text($text); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Adds an xhtml child to element. |
||
37 | * |
||
38 | * @param XHtmlElement $object The element to become a child of element |
||
39 | */ |
||
40 | public function add(XHtmlOption &$object): void |
||
41 | { |
||
42 | \array_push($this->_siblings, $object); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * The CDATA section of Element. |
||
47 | * |
||
48 | * @param string $text Text content of the element |
||
49 | */ |
||
50 | public function set_text($text): void |
||
51 | { |
||
52 | if ($text) { |
||
53 | $this->_text = \htmlspecialchars($text); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | public function fetch() |
||
60 | } |
||
61 | |||
62 | public function _html() |
||
63 | { |
||
64 | $this->_htmlcode = "<{$this->_element}"; |
||
65 | |||
66 | foreach ($this->_attributes as $attribute => $value) { |
||
67 | if (!empty($value)) { |
||
68 | $this->_htmlcode .= \sprintf(' %s="%s" ', $attribute, $value); |
||
69 | } |
||
70 | } |
||
71 | $this->_htmlcode .= '>'; |
||
72 | |||
73 | if ($this->_text) { |
||
74 | $this->_htmlcode .= $this->_text; |
||
75 | } |
||
76 | |||
77 | foreach ($this->_siblings as $obj) { |
||
78 | $this->_htmlcode .= $obj->fetch(); |
||
79 | } |
||
80 | |||
81 | $this->_htmlcode .= "</{$this->_element}>"; |
||
82 | |||
83 | return $this->_htmlcode; |
||
84 | } |
||
85 | |||
86 | // Returns siblings of Element |
||
87 | public function get_siblings() |
||
90 | } |
||
91 | |||
92 | public function has_siblings() |
||
95 | } |
||
96 | } |
||
97 |