public static function resolve(string $path, bool $absolute = false)
    {
        $path = static::normalize($path);
        if (strpos($path, DIRECTORY_SEPARATOR) === 0) {
            // This was an absolute string, so keep it that way.
            $absolute = true;
        }
        /** @noinspection SpellCheckingInspection */
        $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
        $absolutes = array();
        foreach ($parts as $part) {
            if ('.' == $part) {
                continue;
            }
            if ('..' == $part) {
                array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }
        $newPath = implode(DIRECTORY_SEPARATOR, $absolutes);

        if ($absolute === true) {
            $newPath = sprintf("%s%s", DIRECTORY_SEPARATOR, $newPath);
        }

        return $newPath;
    }