public function getPort(): int
    {
        if (!isset($this->segments['port'])) {
            throw new UrlException('Unable to get port for ' . $this->url);
        }

        return (int)$this->segments['port'];
    }