public function getRootUrl($hasProtocol = true)
    {
        $url = $this->getServerName();
        $protocol = $hasProtocol ? $this->getProtocol() : '';
        if (!empty($protocol)) {
            $url = $protocol . $url;
        }
        if (!in_array((integer)$this->getServer('SERVER_PORT'), [80, 443], true)) {
            $url .= ':' . $this->getServer('SERVER_PORT');
        }
        return $url;
    }