1616 */
1717class TableDiff extends AbstractDiff
1818{
19- const STRATEGY_MATCHING = 'matching ' ;
20- const STRATEGY_RELATIVE = 'relative ' ;
21-
2219 /**
2320 * @var null|Table
2421 */
@@ -69,18 +66,6 @@ public function __construct($oldText, $newText, $encoding, $specialCaseTags, $gr
6966 $ this ->purifier = new \HTMLPurifier ($ config );
7067 }
7168
72- public function setStrategy ($ strategy )
73- {
74- $ this ->strategy = $ strategy ;
75-
76- return $ this ;
77- }
78-
79- public function getStrategy ()
80- {
81- return $ this ->strategy ;
82- }
83-
8469 public function build ()
8570 {
8671 $ this ->buildTableDoms ();
@@ -185,26 +170,18 @@ protected function diffTableContent()
185170 $ newMatchData [$ newIndex ] = array ();
186171 }
187172
188- $ oldText = $ oldRow ->getInnerHtml ();
189- $ newText = $ newRow ->getInnerHtml ();
190-
191173 // similar_text
192- // $percentage = null;
193- // similar_text($oldText, $newText, $percentage);
194174 $ percentage = $ this ->getMatchPercentage ($ oldRow , $ newRow );
195175
196176 $ oldMatchData [$ oldIndex ][$ newIndex ] = $ percentage ;
197177 $ newMatchData [$ newIndex ][$ oldIndex ] = $ percentage ;
198178 }
199179 }
200180
201- $ matches = $ this ->getRowMatches ($ oldMatchData , $ newMatchData );
202-
203- addDebugOutput ($ matches , __METHOD__ );
204-
205181 // new solution for diffing rows
206182 switch ($ this ->strategy ) {
207183 case self ::STRATEGY_MATCHING :
184+ $ matches = $ this ->getRowMatches ($ oldMatchData , $ newMatchData );
208185 $ this ->diffTableRowsWithMatches ($ oldRows , $ newRows , $ matches );
209186 break ;
210187
@@ -213,6 +190,7 @@ protected function diffTableContent()
213190 break ;
214191
215192 default :
193+ $ matches = $ this ->getRowMatches ($ oldMatchData , $ newMatchData );
216194 $ this ->diffTableRowsWithMatches ($ oldRows , $ newRows , $ matches );
217195 break ;
218196 }
@@ -309,7 +287,6 @@ protected function processEqualOperation($operation, $oldRows, $newRows, &$appli
309287
310288 foreach ($ targetNewRows as $ index => $ newRow ) {
311289 if (!isset ($ targetOldRows [$ index ])) {
312- addDebugOutput ('failed finding matchign row ' , __METHOD__ );
313290 continue ;
314291 }
315292
@@ -433,7 +410,7 @@ protected function diffTableRows($oldRows, $newRows, $oldMatchData)
433410
434411 if (false !== $ otherMatchBetter && $ newCount > $ oldCount && $ difference > 0 ) {
435412 // insert row as new
436- $ this ->diffAndAppendRows (null , $ row , $ appliedRowSpans, true );
413+ $ this ->diffAndAppendRows (null , $ row , $ appliedRowSpans );
437414 $ difference --;
438415
439416 continue ;
0 commit comments