Passed
Pull Request — master (#9)
by Michael
03:24
created

Text_Diff_Renderer_unified   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 11
dl 0
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _blockHeader() 0 10 3
A _deleted() 0 3 1
A _changed() 0 3 1
A _added() 0 3 1
1
<?php
2
3
namespace XoopsModules\Mylinks;
4
5
/**
6
 * "Unified" diff renderer.
7
 *
8
 * This class renders the diff in classic "unified diff" format.
9
 *
10
 * $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.2 2004/01/09 21:46:30 chuck Exp $
11
 *
12
 * @package Text_Diff
13
 */
14
class Text_Diff_Renderer_unified extends Text_Diff_Renderer
15
{
16
    /**
17
     * Number of leading context "lines" to preserve.
18
     */
19
    public $_leading_context_lines = 4;
20
21
    /**
22
     * Number of trailing context "lines" to preserve.
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
    public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
34
    {
35
        if (1 != $xlen) {
36
            $xbeg .= ',' . $xlen;
37
        }
38
        if (1 != $ylen) {
39
            $ybeg .= ',' . $ylen;
40
        }
41
42
        return "@@ -$xbeg +$ybeg @@";
43
    }
44
45
    /**
46
     * @param $lines
47
     * @return string
48
     */
49
    public function _added($lines)
50
    {
51
        return $this->_lines($lines, '+');
52
    }
53
54
    /**
55
     * @param $lines
56
     * @return string
57
     */
58
    public function _deleted($lines)
59
    {
60
        return $this->_lines($lines, '-');
61
    }
62
63
    /**
64
     * @param $orig
65
     * @param $final
66
     * @return string
67
     */
68
    public function _changed($orig, $final)
69
    {
70
        return $this->_deleted($orig) . $this->_added($final);
71
    }
72
}
73