Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
80.00% covered (warning)
80.00%
4 / 5
CRAP
95.95% covered (success)
95.95%
71 / 74
InCell
0.00% covered (danger)
0.00%
0 / 1
80.00% covered (warning)
80.00%
4 / 5
32
95.95% covered (success)
95.95%
71 / 74
 characters
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 startTag
0.00% covered (danger)
0.00%
0 / 1
12.42
85.71% covered (warning)
85.71%
18 / 21
 endTag
100.00% covered (success)
100.00%
1 / 1
16
100.00% covered (success)
100.00%
39 / 39
 endDocument
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 closeTheCell
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
9 / 9
<?php
namespace RemexHtml\TreeBuilder;
use RemexHtml\Tokenizer\Attributes;
/**
 * The "in cell" insertion mode
 */
class InCell extends InsertionMode {
    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        $this->dispatcher->inBody->characters( $text, $start, $length,
            $sourceStart, $sourceLength );
    }
    public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
        switch ( $name ) {
        case 'caption':
        case 'col':
        case 'colgroup':
        case 'tbody':
        case 'td':
        case 'tfoot':
        case 'th':
        case 'thead':
        case 'tr':
            if ( !$this->builder->stack->isInTableScope( 'td' )
              && !$this->builder->stack->isInTableScope( 'th' )
            ) {
                $this->builder->error( "<$name> tag should close the cell but none is in scope",
                    $sourceStart );
                return;
            }
            $this->closeTheCell( $sourceStart )
                ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength );
            break;
        default:
            $this->dispatcher->inBody->startTag(
                $name, $attrs, $selfClose, $sourceStart, $sourceLength );
        }
    }
    public function endTag( $name, $sourceStart, $sourceLength ) {
        $builder = $this->builder;
        $stack = $builder->stack;
        $dispatcher = $this->dispatcher;
        switch ( $name ) {
        case 'td':
        case 'th':
            if ( !$stack->isInTableScope( $name ) ) {
                $builder->error( "</$name> encountered but there is no $name in scope, ignoring",
                    $sourceStart );
                return;
            }
            $builder->generateImpliedEndTags( false, $sourceStart );
            if ( $stack->current->htmlName !== $name ) {
                $builder->error( "</$name> encountered when there are tags open " .
                    "which can't be closed automatically", $sourceStart );
            }
            $builder->popAllUpToName( $name, $sourceStart, $sourceLength );
            $builder->afe->clearToMarker();
            $dispatcher->switchMode( Dispatcher::IN_ROW );
            break;
        case 'body':
        case 'caption':
        case 'col':
        case 'colgroup':
        case 'html':
            $builder->error( "unexpected </$name> in cell, ignoring", $sourceStart );
            return;
        case 'table':
        case 'tbody':
        case 'tfoot':
        case 'thead':
        case 'tr':
            if ( !$stack->isInTableScope( $name ) ) {
                $builder->error( "</$name> encountered but there is no $name in scope, ignoring",
                    $sourceStart );
                return;
            }
            $this->closeTheCell( $sourceStart )
                ->endTag( $name, $sourceStart, $sourceLength );
            break;
        default:
            $dispatcher->inBody->endTag( $name, $sourceStart, $sourceLength );
        }