private static function mergeTwoValues($originalValue, $newValue, $parentKeys)
    {
        $originalIsArray = is_array($originalValue);
        $newIsArray = is_array($newValue);

        if ($originalIsArray && $newIsArray) {
            return self::mergeArraysRecursively($originalValue, $newValue, $parentKeys);
        }
        elseif (!$originalIsArray && !$newIsArray) {
            // Value from the second array overrides the first:
            return $newValue;
        }
        else {
            throw new InconsistentKeyTypes($originalValue, $newValue, implode('.', $parentKeys));
        }
    }
private static function mergeTwoValues($originalValue, $newValue, $parentKeys)
    {
        $originalIsArray = is_array($originalValue);
        $newIsArray = is_array($newValue);

        if ($originalIsArray && $newIsArray) {
            return self::mergeArraysRecursively($originalValue, $newValue, $parentKeys);
        }
        elseif (!$originalIsArray && !$newIsArray) {
            // Value from the second array overrides the first:
            return $newValue;
        }
        else {
            throw new InconsistentKeyTypes($originalValue, $newValue, implode('.', $parentKeys));
        }
    }
private static function mergeTwoValues ( $ originalValue , $ newValue , $ parentKeys ) { $ originalIsArray = is_array ( $ originalValue ) ; $ newIsArray = is_array ( $ newValue ) ; if ( $ originalIsArray && $ newIsArray ) { return self :: mergeArraysRecursively ( $ originalValue , $ newValue , $ parentKeys ) ; } elseif ( ! $ originalIsArray && ! $ newIsArray ) { // Value from the second array overrides the first: return $ newValue ; } else { throw new InconsistentKeyTypes ( $ originalValue , $ newValue , implode ( '.' , $ parentKeys ) ) ; } }
Merge two values and return the result.

This merges the values when they are arrays, and overrides the value in
the first array with the second otherwise.

@param  mixed $originalValue First value to merge.
@param  mixed $newValue Second value to merge.
@param  array $parentKeys Key path to parents used for error reporting.

@throws \Best\DotNotation\InconsistentKeyTypes if a key that already exists is changed to an
array, or if an array is changed to a string.
@return array The merged values as an array, or the second value if both are scalars.
Merge two values and return the result .