Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 49
TokenGeneratorHandler
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 8
72
0.00% covered (danger)
0.00%
0 / 49
 startDocument
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 endDocument
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 error
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 characters
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 8
 startTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 8
 endTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 doctype
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 7
 comment
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
<?php
namespace RemexHtml\Tokenizer;
/**
 * The handler which converts events to tokens arrays for TokenGenerator
 */
class TokenGeneratorHandler implements TokenHandler {
    public $tokens = [];
    public function startDocument( Tokenizer $tokenizer, $fragmentNamespace, $fragmentName ) {
        $this->tokens[] = [
            'type' => 'startDocument',
            'fragmentNamespace' => $fragmentNamespace,
            'fragmentName' => $fragmentName
        ];
    }
    public function endDocument( $pos ) {
        $this->tokens[] = [ 'type' => 'endDocument' ];
    }
    public function error( $text, $pos ) {
        $this->tokens[] = [
            'type' => 'error',
            'text' => $text,
            'sourceStart' => $pos
        ];
    }
    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        $this->tokens[] = [
            'type' => 'text',
            'text' => $text,
            'start' => $start,
            'length' => $length,
            'sourceStart' => $sourceStart,
            'sourceLength' => $sourceLength ];
    }
    public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
        $this->tokens[] = [
            'type' => 'startTag',
            'name' => $name,
            'attrs' => $attrs,
            'selfClose' => $selfClose,
            'sourceStart' => $sourceStart,
            'sourceLength' => $sourceLength ];
    }
    public function endTag( $name, $sourceStart, $sourceLength ) {
        $this->tokens[] = [
            'type' => 'endTag',
            'name' => $name,
            'sourceStart' => $sourceStart,
            'sourceLength' => $sourceLength ];
    }
    public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) {
        $this->tokens[] = [
            'type' => 'doctype',
            'name' => $name,
            'public' => $public,
            'system' => $system,
            'quirks' => $quirks ];
    }
    public function comment( $text, $sourceStart, $sourceLength ) {
        $this->tokens[] = [
            'type' => 'comment',
            'text' => $text,
            'sourceStart' => $sourceStart,
            'sourceLength' => $sourceLength ];
    }
}