Uri::__construct( $uri = '' )

In this article

Source

public function __construct(string $uri = '')
{
    if ('' !== $uri) {
        if (\false === $parts = \parse_url($uri)) {
            throw new \InvalidArgumentException(\sprintf('Unable to parse URI: "%s"', $uri));
        }
        // Apply parse_url parts to a URI.
        $this->scheme = isset($parts['scheme']) ? \strtr($parts['scheme'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') : '';
        $this->userInfo = $parts['user'] ?? '';
        $this->host = isset($parts['host']) ? \strtr($parts['host'], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') : '';
        $this->port = isset($parts['port']) ? $this->filterPort($parts['port']) : null;
        $this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : '';
        $this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : '';
        $this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : '';
        if (isset($parts['pass'])) {
            $this->userInfo .= ':' . $parts['pass'];
        }
    }
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.