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