Ejemplo n.º 1
0
 /**
  * Apply patches and compute merge faults
  *
  * @param array $patches
  * @param string $text
  * @return array
  */
 private function applyPatches($patches, $text)
 {
     $dmp = WUMDiffMatchPatchWrapper::getInstance();
     global $wumMatchDistance;
     $dmp->Match_Distance = $wumMatchDistance;
     $result = $dmp->patch_apply($text, $patches);
     $mergeFaults = array();
     for ($i = 0; $i < count($result[1]); $i++) {
         if (!$result[1][$i]) {
             $mergeFaults[] = $patches[$i];
         }
     }
     return array('mergedText' => $result[0], 'mergeFaults' => $mergeFaults);
 }