Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
UnifiedDiffFormatter
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 5
42
0.00% covered (danger)
0.00%
0 / 1
 lines
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 added
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 deleted
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 changed
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 blockHeader
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Portions taken from phpwiki-1.3.3.
4 *
5 * Copyright © 2000, 2001 Geoffrey T. Dairiki <dairiki@dairiki.org>
6 * You may copy this code freely under the conditions of the GPL.
7 *
8 * @license GPL-2.0-or-later
9 * @file
10 * @ingroup DifferenceEngine
11 */
12
13namespace Wikimedia\Diff;
14
15/**
16 * A formatter that outputs unified diffs
17 * @newable
18 * @ingroup DifferenceEngine
19 */
20class UnifiedDiffFormatter extends DiffFormatter {
21
22    /** @var int */
23    protected $leadingContextLines = 2;
24
25    /** @var int */
26    protected $trailingContextLines = 2;
27
28    /**
29     * @param string[] $lines
30     * @param string $prefix
31     */
32    protected function lines( $lines, $prefix = ' ' ) {
33        foreach ( $lines as $line ) {
34            $this->writeOutput( "{$prefix}{$line}\n" );
35        }
36    }
37
38    /**
39     * @param string[] $lines
40     */
41    protected function added( $lines ) {
42        $this->lines( $lines, '+' );
43    }
44
45    /**
46     * @param string[] $lines
47     */
48    protected function deleted( $lines ) {
49        $this->lines( $lines, '-' );
50    }
51
52    /**
53     * @param string[] $orig
54     * @param string[] $closing
55     */
56    protected function changed( $orig, $closing ) {
57        $this->deleted( $orig );
58        $this->added( $closing );
59    }
60
61    /**
62     * @param int $xbeg
63     * @param int $xlen
64     * @param int $ybeg
65     * @param int $ylen
66     *
67     * @return string
68     */
69    protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
70        return "@@ -$xbeg,$xlen +$ybeg,$ylen @@";
71    }
72
73}
74
75/** @deprecated class alias since 1.41 */
76class_alias( UnifiedDiffFormatter::class, 'UnifiedDiffFormatter' );