21
21
class Context extends RendererAbstract
22
22
{
23
23
/**
24
- * @var array Array of the different op code tags and how they map to the context diff equivalent.
24
+ * @var array Array of the different op- code tags and how they map to the context diff-view equivalent.
25
25
*/
26
- private $ tagMap = array (
27
- 'insert ' => '+ ' ,
28
- 'delete ' => '- ' ,
29
- 'replace ' => '! ' ,
30
- 'equal ' => ' '
31
- ) ;
26
+ private $ tagMap = [
27
+ 'insert ' => '+ ' ,
28
+ 'delete ' => '- ' ,
29
+ 'replace ' => '! ' ,
30
+ 'equal ' => ' '
31
+ ] ;
32
32
33
33
/**
34
- * Render and return a context formatted (old school!) diff file .
34
+ * Render and return a context formatted (old school!) diff-view .
35
35
*
36
- * @return string The generated context diff.
36
+ * @return string The generated context diff-view .
37
37
*/
38
38
public function render (): string
39
39
{
40
- $ diff = '' ;
41
- $ opCodes = $ this ->diff ->getGroupedOpcodes ();
40
+ $ diff = '' ;
41
+ $ opCodes = $ this ->diff ->getGroupedOpcodes ();
42
+
42
43
foreach ($ opCodes as $ group ) {
43
- $ diff .= "*************** \n" ;
44
- $ lastItem = count ($ group ) - 1 ;
45
- $ i1 = $ group ['0 ' ]['1 ' ];
46
- $ i2 = $ group [$ lastItem ]['2 ' ];
47
- $ j1 = $ group ['0 ' ]['3 ' ];
48
- $ j2 = $ group [$ lastItem ]['4 ' ];
44
+ $ diff .= "*************** \n" ;
45
+ $ lastItem = count ($ group ) - 1 ;
46
+ $ i1 = $ group ['0 ' ]['1 ' ];
47
+ $ i2 = $ group [$ lastItem ]['2 ' ];
48
+ $ j1 = $ group ['0 ' ]['3 ' ];
49
+ $ j2 = $ group [$ lastItem ]['4 ' ];
49
50
50
51
if ($ i2 - $ i1 >= 2 ) {
51
52
$ diff .= '*** ' . ($ group ['0 ' ]['1 ' ] + 1 ) . ', ' . $ i2 . " **** \n" ;
@@ -60,6 +61,7 @@ public function render(): string
60
61
}
61
62
62
63
$ hasVisible = false ;
64
+
63
65
foreach ($ group as $ code ) {
64
66
if ($ code ['0 ' ] == 'replace ' || $ code ['0 ' ] == 'delete ' ) {
65
67
$ hasVisible = true ;
@@ -82,6 +84,7 @@ public function render(): string
82
84
}
83
85
84
86
$ hasVisible = false ;
87
+
85
88
foreach ($ group as $ code ) {
86
89
if ($ code ['0 ' ] == 'replace ' || $ code ['0 ' ] == 'insert ' ) {
87
90
$ hasVisible = true ;
@@ -105,6 +108,7 @@ public function render(): string
105
108
}
106
109
}
107
110
}
111
+
108
112
return $ diff ;
109
113
}
110
114
}
0 commit comments