Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Tracer | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| log | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\Parsoid\Wt2Html; |
| 5 | |
| 6 | use Wikimedia\WikiPEG\DefaultTracer; |
| 7 | |
| 8 | class Tracer extends DefaultTracer { |
| 9 | private string $text; |
| 10 | |
| 11 | public function __construct( string $text ) { |
| 12 | $this->text = $text; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * @param array{location:\Wikimedia\WikiPEG\LocationRange,type:string,rule:string,args?:array} $event |
| 17 | */ |
| 18 | protected function log( $event ): void { |
| 19 | $offset = $event['location']->start->offset; |
| 20 | print str_pad( |
| 21 | '' . $event['location'], |
| 22 | 20 |
| 23 | ) |
| 24 | . str_pad( 'c:' . json_encode( $this->text[$offset] ?? '' ), 10 ) |
| 25 | . str_pad( $event['type'], 10 ) . ' ' |
| 26 | . str_repeat( ' ', $this->indentLevel ) . $event['rule'] |
| 27 | . $this->formatArgs( $event['args'] ?? null ) |
| 28 | . "\n"; |
| 29 | } |
| 30 | } |