@@ -76,8 +76,6 @@ public function build()
7676
7777 $ this ->indexCellValues ($ this ->newTable );
7878
79- // $matches = $this->getMatches();
80-
8179 $ this ->diffTableContent ();
8280
8381 return $ this ->content ;
@@ -739,108 +737,6 @@ protected function indexCellValues(Table $table)
739737 }
740738 }
741739
742- protected function getMatches ()
743- {
744- $ matches = array ();
745-
746- $ oldRowCount = count ($ this ->oldTable ->getRows ());
747- $ newRowCount = count ($ this ->newTable ->getRows ());
748-
749- $ startInOld = new TablePosition (0 , 0 );
750- $ startInNew = new TablePosition (0 , 0 );
751- $ endInOld = new TablePosition (
752- $ oldRowCount - 1 , count ($ this ->oldTable ->getRow ($ oldRowCount - 1 )->getCells ()) - 1
753- );
754- $ endInNew = new TablePosition (
755- $ newRowCount - 1 , count ($ this ->newTable ->getRow ($ newRowCount - 1 )->getCells ()) - 1
756- );
757-
758- $ this ->findMatches ($ startInOld , $ endInOld , $ startInNew , $ endInNew , $ matches );
759-
760- return $ matches ;
761- }
762-
763- protected function findMatches ($ startInOld , $ endInOld , $ startInNew , $ endInNew , &$ matches )
764- {
765- $ match = $ this ->findMatch ($ startInOld , $ endInOld , $ startInNew , $ endInNew );
766- if ($ match !== null ) {
767- if (TablePosition::compare ($ startInOld , $ match ->getStartInOld ()) < 0 &&
768- TablePosition::compare ($ startInNew , $ match ->getStartInNew ()) < 0
769- ) {
770- $ this ->findMatches (
771- $ startInOld ,
772- $ match ->getStartInOld (),
773- $ startInNew ,
774- $ match ->getStartInNew (),
775- $ matches
776- );
777- }
778-
779- $ matches [] = $ match ;
780-
781- if (TablePosition::compare ($ match ->getEndInOld (), $ endInOld ) < 0 &&
782- TablePosition::compare ($ match ->getEndInNew (), $ endInNew ) < 0
783- ) {
784- $ this ->findMatches ($ match ->getEndInOld (), $ endInOld , $ match ->getEndInNew (), $ endInNew , $ matches );
785- }
786- }
787- }
788-
789- protected function findMatch ($ startInOld , $ endInOld , $ startInNew , $ endInNew )
790- {
791- $ bestMatchInOld = $ startInOld ;
792- $ bestMatchInNew = $ startInNew ;
793- $ bestMatchSize = 0 ;
794- $ matchLengthAt = array ();
795-
796- $ currentPos = $ startInOld ;
797-
798- while ($ currentPos && TablePosition::compare ($ currentPos , $ endInOld ) < 0 ) {
799- $ newMatchLengthAt = array ();
800- $ oldCell = $ this ->oldTable ->getCellByPosition ($ currentPos );
801-
802- $ value = trim ($ oldCell ->getDomNode ()->textContent );
803-
804- if (!isset ($ this ->cellValues [$ value ])) {
805- $ matchLengthAt = $ newMatchLengthAt ;
806- $ currentPos = $ this ->oldTable ->getPositionAfter ($ currentPos );
807- continue ;
808- }
809-
810- foreach ($ this ->cellValues [$ value ] as $ posInNew ) {
811- if (TablePosition::compare ($ posInNew , $ startInNew ) < 0 ) {
812- continue ;
813- }
814- if (TablePosition::compare ($ posInNew , $ endInNew ) >= 0 ) {
815- break ;
816- }
817-
818- $ posBefore = $ this ->newTable ->getPositionBefore ($ posInNew );
819-
820- $ newMatchLength = 1 + (isset ($ matchLengthAt [(string )$ posBefore ]) ? $ matchLengthAt [(string )$ posBefore ] : 0 );
821- $ newMatchLengthAt [(string )$ posInNew ] = $ newMatchLength ;
822-
823- if ($ newMatchLength > $ bestMatchSize ) {
824- $ bestMatchInOld = $ this ->oldTable ->getPositionBefore ($ currentPos , $ newMatchLength - 1 );
825- $ bestMatchInNew = $ this ->newTable ->getPositionBefore ($ posInNew , $ newMatchLength - 1 );
826- $ bestMatchSize = $ newMatchLength ;
827- }
828- }
829- $ matchLengthAt = $ newMatchLengthAt ;
830-
831- $ currentPos = $ this ->oldTable ->getPositionAfter ($ currentPos );
832- }
833-
834- if ($ bestMatchSize != 0 ) {
835- $ bestEndInOld = $ this ->oldTable ->getPositionAfter ($ bestMatchInOld , $ bestMatchSize );
836- $ bestEndInNew = $ this ->newTable ->getPositionAfter ($ bestMatchInNew , $ bestMatchSize );
837-
838- return new TableMatch ($ bestMatchInOld , $ bestMatchInNew , $ bestEndInOld , $ bestEndInNew );
839- }
840-
841- return null ;
842- }
843-
844740 /**
845741 * @param $tableRow
846742 * @param $currentColumn
0 commit comments