Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| AfterAfterBody | |
0.00% |
0 / 26 |
|
0.00% |
0 / 5 |
90 | |
0.00% |
0 / 1 |
| characters | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
| startTag | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
| endTag | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| endDocument | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| comment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\RemexHtml\TreeBuilder; |
| 5 | |
| 6 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 7 | |
| 8 | /** |
| 9 | * The "after after body" insertion mode |
| 10 | */ |
| 11 | class AfterAfterBody extends InsertionMode { |
| 12 | /** @inheritDoc */ |
| 13 | public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
| 14 | [ $part1, $part2 ] = $this->splitInitialMatch( true, "\t\n\f\r ", |
| 15 | $text, $start, $length, $sourceStart, $sourceLength ); |
| 16 | [ $start, $length, $sourceStart, $sourceLength ] = $part1; |
| 17 | if ( $length ) { |
| 18 | $this->builder->insertCharacters( $text, $start, $length, $sourceStart, $sourceLength ); |
| 19 | } |
| 20 | |
| 21 | [ $start, $length, $sourceStart, $sourceLength ] = $part2; |
| 22 | if ( !$length ) { |
| 23 | return; |
| 24 | } |
| 25 | $this->builder->error( "unexpected non-whitespace characters after after body", |
| 26 | $sourceStart ); |
| 27 | $this->dispatcher->switchMode( Dispatcher::IN_BODY ) |
| 28 | ->characters( $text, $start, $length, $sourceStart, $sourceLength ); |
| 29 | } |
| 30 | |
| 31 | /** @inheritDoc */ |
| 32 | public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
| 33 | $builder = $this->builder; |
| 34 | $dispatcher = $this->dispatcher; |
| 35 | |
| 36 | switch ( $name ) { |
| 37 | case 'html': |
| 38 | $dispatcher->inBody->startTag( |
| 39 | $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
| 40 | break; |
| 41 | |
| 42 | default: |
| 43 | $builder->error( "unexpected start tag after after body", $sourceStart ); |
| 44 | $dispatcher->switchMode( Dispatcher::IN_BODY ) |
| 45 | ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** @inheritDoc */ |
| 50 | public function endTag( $name, $sourceStart, $sourceLength ) { |
| 51 | $this->builder->error( "unexpected end tag after after body", $sourceStart ); |
| 52 | $this->dispatcher->switchMode( Dispatcher::IN_BODY ) |
| 53 | ->endTag( $name, $sourceStart, $sourceLength ); |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | public function endDocument( $pos ) { |
| 58 | $this->builder->stopParsing( $pos ); |
| 59 | } |
| 60 | |
| 61 | /** @inheritDoc */ |
| 62 | public function comment( $text, $sourceStart, $sourceLength ) { |
| 63 | $this->builder->comment( [ TreeBuilder::ROOT, null ], $text, $sourceStart, $sourceLength ); |
| 64 | } |
| 65 | } |