Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| TableDiffFormatterFullContext | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| format | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\AbuseFilter; |
| 4 | |
| 5 | use Wikimedia\Diff\Diff; |
| 6 | use Wikimedia\Diff\TableDiffFormatter; |
| 7 | |
| 8 | /** |
| 9 | * Like TableDiffFormatter, but will always render the full context (even for empty diffs). |
| 10 | * |
| 11 | * @todo Consider moving to MW core (as a separate class, or as an option to TableDiffFormatter) |
| 12 | * |
| 13 | * @internal |
| 14 | */ |
| 15 | class TableDiffFormatterFullContext extends TableDiffFormatter { |
| 16 | /** |
| 17 | * Format a diff. |
| 18 | * |
| 19 | * @param Diff $diff |
| 20 | * @return string The formatted output. |
| 21 | */ |
| 22 | public function format( $diff ) { |
| 23 | $xlen = $ylen = 0; |
| 24 | |
| 25 | // Calculate the length of the left and the right side |
| 26 | foreach ( $diff->edits as $edit ) { |
| 27 | if ( $edit->orig ) { |
| 28 | $xlen += count( $edit->orig ); |
| 29 | } |
| 30 | if ( $edit->closing ) { |
| 31 | $ylen += count( $edit->closing ); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // Just render the diff with no preprocessing |
| 36 | $this->startDiff(); |
| 37 | $this->block( 1, $xlen, 1, $ylen, $diff->edits ); |
| 38 | return $this->endDiff(); |
| 39 | } |
| 40 | } |