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%
68 / 68
InTableBody
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
28
100.00% covered (success)
100.00%
68 / 68
 characters
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 startTag
100.00% covered (success)
100.00%
1 / 1
13
100.00% covered (success)
100.00%
37 / 37
 endTag
100.00% covered (success)
100.00%
1 / 1
13
100.00% covered (success)
100.00%
26 / 26
 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 body" insertion mode
 */
class InTableBody extends InsertionMode {
    private static $tableBodyContext = [
        'tbody' => true,
        'tfoot' => true,
        'thead' => true,
        'template' => true,
        'html' => true
    ];
    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        $this->dispatcher->inTable->characters( $text, $start, $length,
            $sourceStart, $sourceLength );
    }
    public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
        $builder = $this->builder;
        $stack = $builder->stack;
        $dispatcher = $this->dispatcher;
        switch ( $name ) {
        case 'tr':
            $builder->clearStackBack( self::$tableBodyContext, $sourceStart );
            $builder->insertElement( $name, $attrs, false, $sourceStart, $sourceLength );
            $dispatcher->switchMode( Dispatcher::IN_ROW );
            break;
        case 'th':
        case 'td':
            $builder->error( "<$name> encountered in table body (not row) mode", $sourceStart );
            $builder->clearStackBack( self::$tableBodyContext, $sourceStart );
            $builder->insertElement( 'tr', new PlainAttributes, false, $sourceStart, 0 );
            $dispatcher->switchMode( Dispatcher::IN_ROW )
                ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength );
            break;
        case 'caption':
        case 'col':
        case 'colgroup':
        case 'tbody':
        case 'tfoot':
        case 'thead':
            if ( !$stack->isInTableScope( 'tbody' )
              && !$stack->isInTableScope( 'thead' )
              && !$stack->isInTableScope( 'tfoot' )
            ) {
                $builder->error( "<$name> encountered in table body mode " .