44
55class HtmlDiff
66{
7+ public static $ defaultSpecialCaseTags = array ('strong ' , 'b ' , 'i ' , 'big ' , 'small ' , 'u ' , 'sub ' , 'sup ' , 'strike ' , 's ' , 'p ' );
8+ public static $ defaultSpecialCaseChars = array ('. ' , ', ' , '( ' , ') ' , '\'' );
9+ public static $ defaultGroupDiffs = true ;
10+
711 private $ content ;
812 private $ oldText ;
913 private $ newText ;
@@ -13,19 +17,27 @@ class HtmlDiff
1317 private $ encoding ;
1418 private $ specialCaseOpeningTags = array ();
1519 private $ specialCaseClosingTags = array ();
16- private $ specialCaseTags = array ('strong ' , 'b ' , 'i ' , 'big ' , 'small ' , 'u ' , 'sub ' , 'sup ' , 'strike ' , 's ' , 'p ' );
17- private $ specialCaseChars = array ('. ' , ', ' , '( ' , ') ' , '\'' );
18- private $ groupDiffs = true ;
19-
20- public function __construct ($ oldText , $ newText , $ encoding = 'UTF-8 ' , $ specialCaseTags = array (), $ groupDiffs = true )
21- {
20+ private $ specialCaseTags ;
21+ private $ specialCaseChars ;
22+ private $ groupDiffs ;
23+
24+ public function __construct ($ oldText , $ newText , $ encoding = 'UTF-8 ' , $ specialCaseTags = null , $ groupDiffs = null )
25+ {
26+ if ($ specialCaseTags === null ) {
27+ $ specialCaseTags = static ::$ defaultSpecialCaseTags ;
28+ }
29+
30+ if ($ groupDiffs === null ) {
31+ $ groupDiffs = static ::$ defaultGroupDiffs ;
32+ }
33+
2234 $ this ->oldText = $ this ->purifyHtml (trim ($ oldText ));
2335 $ this ->newText = $ this ->purifyHtml (trim ($ newText ));
2436 $ this ->encoding = $ encoding ;
2537 $ this ->content = '' ;
2638 $ this ->groupDiffs = $ groupDiffs ;
27-
2839 $ this ->setSpecialCaseTags ($ specialCaseTags );
40+ $ this ->setSpecialCaseChars (static ::$ defaultSpecialCaseChars );
2941 }
3042
3143 public function setSpecialCaseChars (array $ chars )
0 commit comments