Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
121 / 121
InTable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
39
100.00% covered (success)
100.00%
121 / 121
 characters
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
11 / 11
 startTag
100.00% covered (success)
100.00%
1 / 1
21
100.00% covered (success)
100.00%
76 / 76
 endTag
100.00% covered (success)
100.00%
1 / 1
15
100.00% covered (success)
100.00%
32 / 32
 endDocument
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?php
namespace RemexHtml\TreeBuilder;
use RemexHtml\Tokenizer\Attributes;
use RemexHtml\Tokenizer\PlainAttributes;
/**
 * The "in table" insertion mode
 */
class InTable extends InsertionMode {
    /**
     * The tag names that are cleared when we "clear the stack back to a table context"
     */
    private static $tableContext = [
        'table' => true,
        'template' => true,
        'html' => true
    ];
    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        $allowed = [
            'table' => true,
            'tbody' => true,
            'tfoot' => true,
            'thead' => true,
            'tr' => true ];
        if ( isset( $allowed[$this->builder->stack->current->htmlName] ) ) {
            $this->builder->pendingTableCharacters = [];
            $this->dispatcher->switchAndSave( Dispatcher::IN_TABLE_TEXT )
                ->characters( $text, $start, $length, $sourceStart, $sourceLength );
        } else {
            $this->builder->error( 'unexpected text in table, fostering', $sourceStart );
            $this->builder->fosterParenting = true;
            $this->dispatcher->inBody->characters(
                $text, $start, $length, $sourceStart, $sourceLength );
            $this->builder->fosterParenting = false;
        }
    }
    public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
        $builder = $this->builder;
        $dispatcher = $this->dispatcher;
        $stack = $builder->stack;
        switch ( $name ) {
        case 'caption':
            $builder->clearStackBack( self::$tableContext, $sourceStart );
            $builder->afe->insertMarker();
            $dispatcher->switchMode( Dispatcher::IN_CAPTION );
            $builder->insertElement( $name, $attrs, false,
                $sourceStart, $sourceLength );
            break;