/** * Constructor * * @param string $name Node name * @param array $args Node arguments * @throws InvalidArgumentException If $name is not a string * @throws InvalidArgumentException If $args is not a string */ public function __construct($name = null, $args = null) { if (!is_null($name) && !is_string($name) || $name === "") { throw new InvalidArgumentException("Expected string for node name (e.g. `p`)", 1); } if (!is_null($args) && !is_string($args) || $args === "") { throw new InvalidArgumentException("Expected string for node args (e.g. `id=\"foo\"`)", 1); } parent::__construct(); }
/** * Returns HTML output inc. child nodes * * @return string */ public function output() { $output = '<' . $this->_tagname . ''; if ($this->_attr) { $output .= ' ' . $this->_attr; } $output .= '>'; if ($this->_kind === self::NORMAL) { if ($this->hasChildren()) { $output .= parent::output(); } $output .= '</' . $this->_tagname . '>'; } return $output; }