private function buildFromParts(array $parts)
    {
        $this->withScheme(isset($parts['scheme']) ? $parts['scheme'] : '')
            ->withUserInfo(
                isset($parts['user']) ? $parts['user'] : '',
                isset($parts['pass']) ? ':'.$parts['pass'] : null
            )
            ->withHost(isset($parts['host']) ? $parts['host'] : '')
            ->withPort(!empty($parts['port']) ? $parts['port'] : null)
            ->withPath(isset($parts['path']) ? $parts['path'] : '')
            ->withQuery(isset($parts['query']) ? $parts['query'] : '')
            ->withFragment(isset($parts['fragment']) ? $parts['fragment'] : '');
    }