diff options
Diffstat (limited to 'test/HTML5')
-rw-r--r-- | test/HTML5/Parser/EventStack.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/HTML5/Parser/EventStack.php b/test/HTML5/Parser/EventStack.php new file mode 100644 index 0000000..6f5576e --- /dev/null +++ b/test/HTML5/Parser/EventStack.php @@ -0,0 +1,57 @@ +<?php +namespace HTML5\Parser; +require __DIR__ . '/../TestCase.php'; + +class EventStack implements EventHandler { + protected $stack; + + public function __construct() { + $this->stack = array(); + } + + /** + * Get the event stack. + */ + public function events() { + return $this->stack; + } + + public function depth() { + return count($this->stack); + } + + protected function store($event, $data = NULL) { + $stack[] = array( + 'name' => $event, + 'data' => $data, + ); + } + + public function doctype($name, $publicId, $systemID, $quirks) { + $args = func_get_args(); + $this->store('doctype', $args); + } + + public function startTag($name, $attributes = array(), $selfClosing = FALSE) { + $args = func_get_args(); + $this->store('startTag', $args); + } + + public function endTag($name) { + $this->store('endTag', array($name)); + } + + public function comment($cdata) { + $this->store('comment', array($cdata)); + } + + public function text($cdata) { + $this->store('character', array($cdata)); + } + + public function eof() { + $this->store('eof'); + } + + +} |