MediaWiki master
UnifiedDiffFormatter.php
Go to the documentation of this file.
1<?php
13namespace Wikimedia\Diff;
14
22
24 protected $leadingContextLines = 2;
25
27 protected $trailingContextLines = 2;
28
33 protected function lines( $lines, $prefix = ' ' ) {
34 foreach ( $lines as $line ) {
35 $this->writeOutput( "{$prefix}{$line}\n" );
36 }
37 }
38
42 protected function added( $lines ) {
43 $this->lines( $lines, '+' );
44 }
45
49 protected function deleted( $lines ) {
50 $this->lines( $lines, '-' );
51 }
52
57 protected function changed( $orig, $closing ) {
58 $this->deleted( $orig );
59 $this->added( $closing );
60 }
61
70 protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
71 return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
72 }
73
74}
75
77class_alias( UnifiedDiffFormatter::class, 'UnifiedDiffFormatter' );
Base class for diff formatters.
writeOutput( $text)
Writes a string to the output buffer.
A formatter that outputs unified diffs.
blockHeader( $xbeg, $xlen, $ybeg, $ylen)