33namespace Caxy \HtmlDiff ;
44
55/**
6- * Class AbstractDiff
7- * @package Caxy\HtmlDiff
6+ * Class AbstractDiff.
87 */
98abstract class AbstractDiff
109{
@@ -97,7 +96,7 @@ abstract public function build();
9796 protected function getDiffCache ()
9897 {
9998 if (!$ this ->hasDiffCache ()) {
100- return null ;
99+ return ;
101100 }
102101
103102 $ hash = spl_object_hash ($ this ->getConfig ()->getCacheProvider ());
@@ -296,7 +295,7 @@ public function isGroupDiffs()
296295 */
297296 protected function getOpeningTag ($ tag )
298297 {
299- return " /< " .$ tag ." [^>]*/i " ;
298+ return ' /< ' .$ tag .' [^>]*/i ' ;
300299 }
301300
302301 /**
@@ -306,7 +305,7 @@ protected function getOpeningTag($tag)
306305 */
307306 protected function getClosingTag ($ tag )
308307 {
309- return " </ " .$ tag ." > " ;
308+ return ' </ ' .$ tag .' > ' ;
310309 }
311310
312311 /**
@@ -318,13 +317,13 @@ protected function getClosingTag($tag)
318317 */
319318 protected function getStringBetween ($ str , $ start , $ end )
320319 {
321- $ expStr = explode ( $ start , $ str , 2 );
322- if ( count ( $ expStr ) > 1 ) {
323- $ expStr = explode ( $ end , $ expStr [ 1 ] );
324- if ( count ( $ expStr ) > 1 ) {
325- array_pop ( $ expStr );
320+ $ expStr = explode ($ start , $ str , 2 );
321+ if (count ($ expStr ) > 1 ) {
322+ $ expStr = explode ($ end , $ expStr [ 1 ]);
323+ if (count ($ expStr ) > 1 ) {
324+ array_pop ($ expStr );
326325
327- return implode ( $ end , $ expStr );
326+ return implode ($ end , $ expStr );
328327 }
329328 }
330329
@@ -338,22 +337,22 @@ protected function getStringBetween($str, $start, $end)
338337 */
339338 protected function purifyHtml ($ html )
340339 {
341- if ( class_exists ( 'Tidy ' ) && false ) {
342- $ config = array ( 'output-xhtml ' => true , 'indent ' => false );
340+ if (class_exists ('Tidy ' ) && false ) {
341+ $ config = array ('output-xhtml ' => true , 'indent ' => false );
343342 $ tidy = new tidy ();
344- $ tidy ->parseString ( $ html , $ config , 'utf8 ' );
343+ $ tidy ->parseString ($ html , $ config , 'utf8 ' );
345344 $ html = (string ) $ tidy ;
346345
347- return $ this ->getStringBetween ( $ html , '<body> ' );
346+ return $ this ->getStringBetween ($ html , '<body> ' );
348347 }
349348
350349 return $ html ;
351350 }
352351
353352 protected function splitInputsToWords ()
354353 {
355- $ this ->oldWords = $ this ->convertHtmlToListOfWords ( $ this ->explode ( $ this ->oldText ) );
356- $ this ->newWords = $ this ->convertHtmlToListOfWords ( $ this ->explode ( $ this ->newText ) );
354+ $ this ->oldWords = $ this ->convertHtmlToListOfWords ($ this ->explode ($ this ->oldText ) );
355+ $ this ->newWords = $ this ->convertHtmlToListOfWords ($ this ->explode ($ this ->newText ) );
357356 }
358357
359358 /**
@@ -379,11 +378,11 @@ protected function convertHtmlToListOfWords($characterString)
379378 foreach ($ characterString as $ i => $ character ) {
380379 switch ($ mode ) {
381380 case 'character ' :
382- if ( $ this ->isStartOfTag ( $ character ) ) {
381+ if ($ this ->isStartOfTag ($ character) ) {
383382 if ($ current_word != '' ) {
384383 $ words [] = $ current_word ;
385384 }
386- $ current_word = " < " ;
385+ $ current_word = ' < ' ;
387386 $ mode = 'tag ' ;
388387 } elseif (preg_match ("/\s/ " , $ character )) {
389388 if ($ current_word !== '' ) {
@@ -394,7 +393,7 @@ protected function convertHtmlToListOfWords($characterString)
394393 } else {
395394 if (
396395 (ctype_alnum ($ character ) && (strlen ($ current_word ) == 0 || $ this ->isPartOfWord ($ current_word ))) ||
397- (in_array ($ character , $ this ->config ->getSpecialCaseChars ()) && isset ($ characterString [$ i+ 1 ]) && $ this ->isPartOfWord ($ characterString [$ i+ 1 ]))
396+ (in_array ($ character , $ this ->config ->getSpecialCaseChars ()) && isset ($ characterString [$ i + 1 ]) && $ this ->isPartOfWord ($ characterString [$ i + 1 ]))
398397 ) {
399398 $ current_word .= $ character ;
400399 } else {
@@ -404,12 +403,12 @@ protected function convertHtmlToListOfWords($characterString)
404403 }
405404 break ;
406405 case 'tag ' :
407- if ( $ this ->isEndOfTag ( $ character ) ) {
408- $ current_word .= " > " ;
406+ if ($ this ->isEndOfTag ($ character) ) {
407+ $ current_word .= ' > ' ;
409408 $ words [] = $ current_word ;
410- $ current_word = "" ;
409+ $ current_word = '' ;
411410
412- if ( !preg_match ('[^\s] ' , $ character ) ) {
411+ if (!preg_match ('[^\s] ' , $ character) ) {
413412 $ mode = 'whitespace ' ;
414413 } else {
415414 $ mode = 'character ' ;
@@ -419,13 +418,13 @@ protected function convertHtmlToListOfWords($characterString)
419418 }
420419 break ;
421420 case 'whitespace ' :
422- if ( $ this ->isStartOfTag ( $ character ) ) {
421+ if ($ this ->isStartOfTag ($ character) ) {
423422 if ($ current_word !== '' ) {
424423 $ words [] = $ current_word ;
425424 }
426- $ current_word = " < " ;
425+ $ current_word = ' < ' ;
427426 $ mode = 'tag ' ;
428- } elseif ( preg_match ( "/\s/ " , $ character ) ) {
427+ } elseif (preg_match ("/\s/ " , $ character) ) {
429428 $ current_word .= $ character ;
430429 $ current_word = preg_replace ('/\s+/S ' , ' ' , $ current_word );
431430 } else {
@@ -454,7 +453,7 @@ protected function convertHtmlToListOfWords($characterString)
454453 */
455454 protected function isStartOfTag ($ val )
456455 {
457- return $ val == " < " ;
456+ return $ val == ' < ' ;
458457 }
459458
460459 /**
@@ -464,7 +463,7 @@ protected function isStartOfTag($val)
464463 */
465464 protected function isEndOfTag ($ val )
466465 {
467- return $ val == " > " ;
466+ return $ val == ' > ' ;
468467 }
469468
470469 /**
@@ -474,7 +473,7 @@ protected function isEndOfTag($val)
474473 */
475474 protected function isWhiteSpace ($ value )
476475 {
477- return !preg_match ( '[^\s] ' , $ value );
476+ return !preg_match ('[^\s] ' , $ value );
478477 }
479478
480479 /**
@@ -485,6 +484,6 @@ protected function isWhiteSpace($value)
485484 protected function explode ($ value )
486485 {
487486 // as suggested by @onassar
488- return preg_split ( '//u ' , $ value );
487+ return preg_split ('//u ' , $ value );
489488 }
490489}
0 commit comments