authentication.php
protected function getCommonPath($first, $second)
    {
        $first  = explode('/', $first);
        $second = explode('/', $second);
        for ($i = 0; $i < min(count($first), count($second)); $i++) {
            if ($first[$i] != $second[$i]) {
                return implode('/', array_slice($first, 0, $i)) . '/';
            }
        }

        return implode('/', $first) . '/';
    }
protected function getCommonPath($first, $second)
    {
        $first  = explode('/', $first);
        $second = explode('/', $second);
        for ($i = 0; $i < min(count($first), count($second)); $i++) {
            if ($first[$i] != $second[$i]) {
                return implode('/', array_slice($first, 0, $i)) . '/';
            }
        }

        return implode('/', $first) . '/';
    }
Finds the common starting path.

@param string $first        Path to compare.
@param string $second       Path to compare.

@return string              Common directories.