Completed
Push — master ( 6dab8b...b949bb )
by Michael
02:15 queued 11s
created

Text_Diff_Renderer_unified::_added()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * "Unified" diff renderer.
5
 *
6
 * This class renders the diff in classic "unified diff" format.
7
 *
8
 * $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.2 2004/01/09 21:46:30 chuck Exp $
9
 *
10
 * @package Text_Diff
11
 */
12
class Text_Diff_Renderer_unified extends Text_Diff_Renderer
13
{
14
    /**
15
     * Number of leading context "lines" to preserve.
16
     */
17
18
    public $_leading_context_lines = 4;
19
20
    /**
21
     * Number of trailing context "lines" to preserve.
22
     */
23
24
    public $_trailing_context_lines = 4;
25
26
    /**
27
     * @param $xbeg
28
     * @param $xlen
29
     * @param $ybeg
30
     * @param $ylen
31
     * @return string
32
     */
33
34
    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
35
    {
36
        if (1 != $xlen) {
37
            $xbeg .= ',' . $xlen;
38
        }
39
40
        if (1 != $ylen) {
41
            $ybeg .= ',' . $ylen;
42
        }
43
44
        return "@@ -$xbeg +$ybeg @@";
45
    }
46
47
    /**
48
     * @param $lines
49
     * @return string
50
     */
51
52
    public function _added($lines)
53
    {
54
        return $this->_lines($lines, '+');
55
    }
56
57
    /**
58
     * @param $lines
59
     * @return string
60
     */
61
62
    public function _deleted($lines)
63
    {
64
        return $this->_lines($lines, '-');
65
    }
66
67
    /**
68
     * @param $orig
69
     * @param $final
70
     * @return string
71
     */
72
73
    public function _changed($orig, $final)
74
    {
75
        return $this->_deleted($orig) . $this->_added($final);
76
    }
77
}
78