HtmlDiff::Operations PHP Метод

Operations() приватный Метод

private Operations ( )
    private function Operations()
    {
        $positionInOld = 0;
        $positionInNew = 0;
        $operations = array();
        $matches = $this->MatchingBlocks();
        $matches[] = new Match(count($this->oldWords), count($this->newWords), 0);
        foreach ($matches as $i => $match) {
            $matchStartsAtCurrentPositionInOld = $positionInOld == $match->StartInOld;
            $matchStartsAtCurrentPositionInNew = $positionInNew == $match->StartInNew;
            $action = 'none';
            if ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == false) {
                $action = 'replace';
            } else {
                if ($matchStartsAtCurrentPositionInOld == true && $matchStartsAtCurrentPositionInNew == false) {
                    $action = 'insert';
                } else {
                    if ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == true) {
                        $action = 'delete';
                    } else {
                        // This occurs if the first few words are the same in both versions
                        $action = 'none';
                    }
                }
            }
            if ($action != 'none') {
                $operations[] = new Operation($action, $positionInOld, $match->StartInOld, $positionInNew, $match->StartInNew);
            }
            if (count($match) != 0) {
                $operations[] = new Operation('equal', $match->StartInOld, $match->EndInOld(), $match->StartInNew, $match->EndInNew());
            }
            $positionInOld = $match->EndInOld();
            $positionInNew = $match->EndInNew();
        }
        return $operations;
    }