Amp\Artax\Uri::parse PHP Method

parse() private method

private parse ( $uri )
    private function parse($uri)
    {
        // PHP 5.4.7 fixed the incorrect parsing of network path references
        // @codeCoverageIgnoreStart
        if (PHP_VERSION_ID >= 50407) {
            return parse_url($uri);
        }
        // @codeCoverageIgnoreEnd
        $isPhp533 = PHP_VERSION_ID >= 50303;
        // PHP < 5.3.3 triggers E_WARNING on failure
        $parts = $isPhp533 ? parse_url($uri) : @parse_url($uri);
        // If no path is present or it's not a network path reference we're finished
        if (!isset($parts['path']) || substr($parts['path'], 0, 2) !== '//') {
            return $parts;
        }
        $schemeExists = isset($parts['scheme']);
        $tmpScheme = $schemeExists ? $parts['scheme'] : 'scheme';
        $tmpUri = $tmpScheme . ':' . $parts['path'];
        $tmpParts = $isPhp533 ? parse_url($tmpUri) : @parse_url($tmpUri);
        $parts['host'] = $tmpParts['host'];
        if (isset($tmpParts['path'])) {
            $parts['path'] = $tmpParts['path'];
        } else {
            unset($parts['path']);
        }
        return $parts;
    }