protected function merge($x, $y, $z, $key)
    {
        // Convert the value into array.
        $ancestor = (strpos($x, PHP_EOL) !== false ? explode(PHP_EOL, $x) : array($x));
        $local = (strpos($y, PHP_EOL) !== false ? explode(PHP_EOL, $y) : array($y));
        $remote = (strpos($z, PHP_EOL) !== false ? explode(PHP_EOL, $z) : array($z));

        // Count number of lines in value or elements in new formed array.
        $count_ancestor = count($ancestor);
        $count_remote = count($remote);
        $count_local = count($local);

        // If number of lines is different in all 3 values.
        // For example : addition in remote and removal in local node.
        //
        // Else get the value of number of lines in updated node.
        // For example : Addition of 2 lines in local.
        // Suppose: $count_ancestor = 2 and $count_remote = 2
        // then, $count_local would be 4 now.
        if ($count_ancestor != $count_local
            && $count_local!= $count_remote
            && $count_ancestor != $count_remote
        ) {
            $merged = $this->linesAddedRemovedAndModified(
                $ancestor,
                $local,
                $remote,
                $count_ancestor,
                $count_local,
                $count_remote
            );
        } else {
            // Store the updated count value in a variable $count.
            if ($count_ancestor == $count_local) {
                $count = $count_remote;
            } else {
                $count = $count_local;
            }
            // If $count > $count_ancestor, that means lines have been added.
            // Otherwise, lines has been removed or modified.
            if ($count > $count_ancestor) {
                $merged = $this->linesAddedOrModified(
                    $ancestor,
                    $local,
                    $remote,
                    $count,
                    $count_remote,
                    $count_ancestor,
                    $count_local
                );
            } else {
                $merged = $this->linesRemovedOrModified(
                    $ancestor,
                    $local,
                    $remote,
                    $count_ancestor,
                    $count_local,
                    $count_remote
                );
            }
        }
        // Convert returned array back to string.
        $merged[$key] = implode(PHP_EOL, $merged);
        return $merged[$key];
    }
protected function merge($x, $y, $z, $key)
    {
        // Convert the value into array.
        $ancestor = (strpos($x, PHP_EOL) !== false ? explode(PHP_EOL, $x) : array($x));
        $local = (strpos($y, PHP_EOL) !== false ? explode(PHP_EOL, $y) : array($y));
        $remote = (strpos($z, PHP_EOL) !== false ? explode(PHP_EOL, $z) : array($z));

        // Count number of lines in value or elements in new formed array.
        $count_ancestor = count($ancestor);
        $count_remote = count($remote);
        $count_local = count($local);

        // If number of lines is different in all 3 values.
        // For example : addition in remote and removal in local node.
        //
        // Else get the value of number of lines in updated node.
        // For example : Addition of 2 lines in local.
        // Suppose: $count_ancestor = 2 and $count_remote = 2
        // then, $count_local would be 4 now.
        if ($count_ancestor != $count_local
            && $count_local!= $count_remote
            && $count_ancestor != $count_remote
        ) {
            $merged = $this->linesAddedRemovedAndModified(
                $ancestor,
                $local,
                $remote,
                $count_ancestor,
                $count_local,
                $count_remote
            );
        } else {
            // Store the updated count value in a variable $count.
            if ($count_ancestor == $count_local) {
                $count = $count_remote;
            } else {
                $count = $count_local;
            }
            // If $count > $count_ancestor, that means lines have been added.
            // Otherwise, lines has been removed or modified.
            if ($count > $count_ancestor) {
                $merged = $this->linesAddedOrModified(
                    $ancestor,
                    $local,
                    $remote,
                    $count,
                    $count_remote,
                    $count_ancestor,
                    $count_local
                );
            } else {
                $merged = $this->linesRemovedOrModified(
                    $ancestor,
                    $local,
                    $remote,
                    $count_ancestor,
                    $count_local,
                    $count_remote
                );
            }
        }
        // Convert returned array back to string.
        $merged[$key] = implode(PHP_EOL, $merged);
        return $merged[$key];
    }
protected function merge ( $ x , $ y , $ z , $ key ) { // Convert the value into array. $ ancestor = ( strpos ( $ x , PHP_EOL ) !== false ? explode ( PHP_EOL , $ x ) : array ( $ x ) ) ; $ local = ( strpos ( $ y , PHP_EOL ) !== false ? explode ( PHP_EOL , $ y ) : array ( $ y ) ) ; $ remote = ( strpos ( $ z , PHP_EOL ) !== false ? explode ( PHP_EOL , $ z ) : array ( $ z ) ) ; // Count number of lines in value or elements in new formed array. $ count_ancestor = count ( $ ancestor ) ; $ count_remote = count ( $ remote ) ; $ count_local = count ( $ local ) ; // If number of lines is different in all 3 values. // For example : addition in remote and removal in local node. // // Else get the value of number of lines in updated node. // For example : Addition of 2 lines in local. // Suppose: $count_ancestor = 2 and $count_remote = 2 // then, $count_local would be 4 now. if ( $ count_ancestor != $ count_local && $ count_local != $ count_remote && $ count_ancestor != $ count_remote ) { $ merged = $ this -> linesAddedRemovedAndModified ( $ ancestor , $ local , $ remote , $ count_ancestor , $ count_local , $ count_remote ) ; } else { // Store the updated count value in a variable $count. if ( $ count_ancestor == $ count_local ) { $ count = $ count_remote ; } else { $ count = $ count_local ; } // If $count > $count_ancestor, that means lines have been added. // Otherwise, lines has been removed or modified. if ( $ count > $ count_ancestor ) { $ merged = $ this -> linesAddedOrModified ( $ ancestor , $ local , $ remote , $ count , $ count_remote , $ count_ancestor , $ count_local ) ; } else { $ merged = $ this -> linesRemovedOrModified ( $ ancestor , $ local , $ remote , $ count_ancestor , $ count_local , $ count_remote ) ; } } // Convert returned array back to string. $ merged [ $ key ] = implode ( PHP_EOL , $ merged ) ; return $ merged [ $ key ] ; }
Function to perform merge. Do not call it directly.

@param string $x
@param string $y
@param string $z
@param mixed $key

@return mixed
@throws Exception
Function to perform merge . Do not call it directly .