Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 41 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
TokenGeneratorHandler | |
0.00% |
0 / 41 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
startDocument | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
endDocument | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
error | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
characters | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
startTag | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
endTag | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
doctype | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
comment | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Wikimedia\RemexHtml\Tokenizer; |
4 | |
5 | /** |
6 | * The handler which converts events to tokens arrays for TokenGenerator |
7 | */ |
8 | class TokenGeneratorHandler implements TokenHandler { |
9 | public $tokens = []; |
10 | |
11 | public function startDocument( Tokenizer $tokenizer, $fragmentNamespace, $fragmentName ) { |
12 | $this->tokens[] = [ |
13 | 'type' => 'startDocument', |
14 | 'fragmentNamespace' => $fragmentNamespace, |
15 | 'fragmentName' => $fragmentName |
16 | ]; |
17 | } |
18 | |
19 | public function endDocument( $pos ) { |
20 | $this->tokens[] = [ 'type' => 'endDocument' ]; |
21 | } |
22 | |
23 | public function error( $text, $pos ) { |
24 | $this->tokens[] = [ |
25 | 'type' => 'error', |
26 | 'text' => $text, |
27 | 'sourceStart' => $pos |
28 | ]; |
29 | } |
30 | |
31 | public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
32 | $this->tokens[] = [ |
33 | 'type' => 'text', |
34 | 'text' => $text, |
35 | 'start' => $start, |
36 | 'length' => $length, |
37 | 'sourceStart' => $sourceStart, |
38 | 'sourceLength' => $sourceLength ]; |
39 | } |
40 | |
41 | public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
42 | $this->tokens[] = [ |
43 | 'type' => 'startTag', |
44 | 'name' => $name, |
45 | 'attrs' => $attrs, |
46 | 'selfClose' => $selfClose, |
47 | 'sourceStart' => $sourceStart, |
48 | 'sourceLength' => $sourceLength ]; |
49 | } |
50 | |
51 | public function endTag( $name, $sourceStart, $sourceLength ) { |
52 | $this->tokens[] = [ |
53 | 'type' => 'endTag', |
54 | 'name' => $name, |
55 | 'sourceStart' => $sourceStart, |
56 | 'sourceLength' => $sourceLength ]; |
57 | } |
58 | |
59 | public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) { |
60 | $this->tokens[] = [ |
61 | 'type' => 'doctype', |
62 | 'name' => $name, |
63 | 'public' => $public, |
64 | 'system' => $system, |
65 | 'quirks' => $quirks ]; |
66 | } |
67 | |
68 | public function comment( $text, $sourceStart, $sourceLength ) { |
69 | $this->tokens[] = [ |
70 | 'type' => 'comment', |
71 | 'text' => $text, |
72 | 'sourceStart' => $sourceStart, |
73 | 'sourceLength' => $sourceLength ]; |
74 | } |
75 | } |