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%
37 / 37
BeforeHead
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
8
100.00% covered (success)
100.00%
36 / 36
 characters
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
10 / 10
 startTag
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
12 / 12
 endTag
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
9 / 9
 endDocument
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
<?php
namespace Wikimedia\RemexHtml\TreeBuilder;
use Wikimedia\RemexHtml\Tokenizer\Attributes;
use Wikimedia\RemexHtml\Tokenizer\PlainAttributes;
/**
 * The "before head" insertion mode
 */
class BeforeHead extends InsertionMode {
    public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
        // Ignore whitespace
        list( $part1, $part2 ) = $this->splitInitialMatch(
            true, "\t\n\f\r ", $text, $start, $length, $sourceStart, $sourceLength );
        list( $start, $length, $sourceStart, $sourceLength ) = $part2;
        if ( !$length ) {
            return;
        }
        // Handle non-whitespace
        $this->builder->headElement = $this->builder->insertElement(
            'head', new PlainAttributes, false, $sourceStart, 0 );
        $this->dispatcher->switchMode( Dispatcher::IN_HEAD )
            ->characters( $text, $start, $length, $sourceStart, $sourceLength );