Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
82.35% covered (warning)
82.35%
14 / 17
CRAP
97.95% covered (success)
97.95%
143 / 146
Dispatcher
0.00% covered (danger)
0.00%
0 / 1
82.35% covered (warning)
82.35%
14 / 17
71
97.95% covered (success)
97.95%
143 / 146
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 switchMode
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 switchAndSave
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 restoreMode
0.00% covered (danger)
0.00%
0 / 1
2.02
83.33% covered (warning)
83.33%
5 / 6
 getHandler
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 isInTableMode
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 reset
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getAppropriateMode
0.00% covered (danger)
0.00%
0 / 1
26
98.08% covered (success)
98.08%
51 / 52
 dispatcherCurrentNode
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
4 / 4
 startDocument
0.00% covered (danger)
0.00%
0 / 1
5.01
93.75% covered (success)
93.75%
15 / 16
 endDocument
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
10 / 10
 error
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 characters
100.00% covered (success)
100.00%
1 / 1
5
100.00% covered (success)
100.00%
9 / 9
 startTag
100.00% covered (success)
100.00%
1 / 1
12
100.00% covered (success)
100.00%
16 / 16
 endTag
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
5 / 5
 doctype
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
7 / 7
 comment
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
5 / 5
<?php
namespace Wikimedia\RemexHtml\TreeBuilder;
use Wikimedia\RemexHtml\HTMLData;
use Wikimedia\RemexHtml\Tokenizer\Attributes;
use Wikimedia\RemexHtml\Tokenizer\TokenHandler;
use Wikimedia\RemexHtml\Tokenizer\Tokenizer;
/**
 * This is the approximate equivalent of the "tree construction dispatcher" in
 * the spec. It receives token events and distributes them to the appropriate
 * insertion mode class. It also implements some things specific to the
 * dispatcher state:
 *   - "Reset the insertion mode appropriately"
 *   - The stack of template insertion modes
 *   - The "original insertion mode"
 */
class Dispatcher implements TokenHandler {
    /**
     * The insertion mode indexes
     */
    public const INITIAL = 1;
    public const BEFORE_HTML = 2;
    public const BEFORE_HEAD = 3;
    public const IN_HEAD = 4;
    public const IN_HEAD_NOSCRIPT = 5;
    public const AFTER_HEAD = 6;
    public const IN_BODY = 7;
    public const TEXT = 8;
    public const IN_TABLE = 9;
    public const IN_TABLE_TEXT = 10;
    public const IN_CAPTION = 11;
    public const IN_COLUMN_GROUP = 12;
    public const IN_TABLE_BODY = 13;
    public const IN_ROW = 14;
    public const IN_CELL = 15;
    public const IN_SELECT = 16;
    public const IN_SELECT_IN_TABLE = 17;
    public const IN_TEMPLATE = 18;
    public const AFTER_BODY = 19;
    public const IN_FRAMESET = 20;
    public const AFTER_FRAMESET = 21;
    public const AFTER_AFTER_BODY = 22;
    public const AFTER_AFTER_FRAMESET = 23;
    public const IN_FOREIGN_CONTENT = 24;
    public const IN_PRE = 25;
    public const IN_TEXTAREA = 26;
    /**
     * The handler class for each insertion mode
     */
    protected static $handlerClasses = [
        self::INITIAL => Initial::class,
        self::BEFORE_HTML => BeforeHtml::class,
        self::BEFORE_HEAD => BeforeHead::class,
        self::IN_HEAD => InHead::class,
        self::IN_HEAD_NOSCRIPT => InHeadNoscript::class,
        self::AFTER_HEAD => AfterHead::class,
        self::IN_BODY => InBody::class,
        self::TEXT => Text::class,
        self::IN_TABLE => InTable::class,
        self::IN_TABLE_TEXT => InTableText::class,
        self::IN_CAPTION => InCaption::class,
        self::IN_COLUMN_GROUP => InColumnGroup::class,
        self::IN_TABLE_BODY => InTableBody::class,
        self::IN_ROW => InRow::class,
        self::IN_CELL => InCell::class,
        self::IN_SELECT => InSelect::class,
        self::IN_SELECT_IN_TABLE => InSelectInTable::class,
        self::IN_TEMPLATE => InTemplate::class,
        self::AFTER_BODY => AfterBody::class,
        self::IN_FRAMESET => InFrameset::class,
        self::AFTER_FRAMESET => AfterFrameset::class,
        self::AFTER_AFTER_BODY => AfterAfterBody::class,
        self::AFTER_AFTER_FRAMESET => AfterAfterFrameset::class,
        self::IN_FOREIGN_CONTENT => InForeignContent::class,
        self::IN_PRE => InPre::class,
        self::IN_TEXTAREA => InTextarea::class,
    ];
    // Public shortcuts for "using the rules for" actions
    /** @var InHead */
    public $inHead;
    /** @var InBody */
    public $inBody;
    /** @var InTable */
    public $inTable;
    /** @var InSelect */
    public $inSelect;
    /** @var InTemplate */
    public $inTemplate;
    /** @var InForeignContent */
    public $inForeign;
    /** @var TreeBuilder */
    protected $builder;
    /**
     * The InsertionMode object for the current insertion mode in HTML content
     *
     * @var InsertionMode
     */
    protected $handler;
    /**
     * An array mapping insertion mode indexes to InsertionMode objects
     *
     * @var InsertionMode[]
     */
    protected $dispatchTable;
    /**
     * The insertion mode index
     *
     * @var int
     */
    protected $mode;
    /**
     * The "original insertion mode" index
     *
     * @var ?int
     */
    protected $originalMode;
    /**
     * The insertion mode sets this to true to acknowledge the tag's
     * self-closing flag.
     *
     * @var bool|null
     */
    public $ack;
    /**
     * The stack of template insertion modes
     *
     * @var TemplateModeStack
     */
    public $templateModeStack;
    /**
     * @param TreeBuilder $builder
     */
    public function __construct( TreeBuilder $builder ) {
        $this->builder = $builder;