2121class Context extends RendererAbstract
2222{
2323 /**
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.
2525 */
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+ ] ;
3232
3333 /**
34- * Render and return a context formatted (old school!) diff file .
34+ * Render and return a context formatted (old school!) diff-view .
3535 *
36- * @return string The generated context diff.
36+ * @return string The generated context diff-view .
3737 */
3838 public function render (): string
3939 {
40- $ diff = '' ;
41- $ opCodes = $ this ->diff ->getGroupedOpcodes ();
40+ $ diff = '' ;
41+ $ opCodes = $ this ->diff ->getGroupedOpcodes ();
42+
4243 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 ' ];
4950
5051 if ($ i2 - $ i1 >= 2 ) {
5152 $ diff .= '*** ' . ($ group ['0 ' ]['1 ' ] + 1 ) . ', ' . $ i2 . " **** \n" ;
@@ -60,6 +61,7 @@ public function render(): string
6061 }
6162
6263 $ hasVisible = false ;
64+
6365 foreach ($ group as $ code ) {
6466 if ($ code ['0 ' ] == 'replace ' || $ code ['0 ' ] == 'delete ' ) {
6567 $ hasVisible = true ;
@@ -82,6 +84,7 @@ public function render(): string
8284 }
8385
8486 $ hasVisible = false ;
87+
8588 foreach ($ group as $ code ) {
8689 if ($ code ['0 ' ] == 'replace ' || $ code ['0 ' ] == 'insert ' ) {
8790 $ hasVisible = true ;
@@ -105,6 +108,7 @@ public function render(): string
105108 }
106109 }
107110 }
111+
108112 return $ diff ;
109113 }
110114}
0 commit comments