public function buildLink(
        string $protocol = null,
        string $host = null,
        $path = null,
        array $query = null,
        string $fragment = null
    ): string {
        if (empty($protocol)) {
            $protocol = (array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) ? 'https' : 'http');
        }

        if (empty($host)) {
            $host = $_SERVER['HTTP_HOST'];
        }

        $link = "$protocol://$host/";

        if (!empty($path)) {
            if (is_string($path)) {
                $link .= $path;
            } elseif (is_array($path)) {
                $path = $this->pathHelper->joinArray($path);
                $link .= $path;
            } else {
                $type = gettype($path);
                throw new InvalidArgumentException(
                    "Expected a the path argument to be of type string or array, $type given!",
                    1530398563
                );
            }
        }

        if (!empty($query)) {
            $link .= '?'.array_keys($query)[0].'='.array_shift($query);

            foreach ($query as $key => $value) {
                $link .= "&$key=$value";
            }
        }

        if (!empty($fragment)) {
            $link .= "#$fragment";
        }

        return $link;
    }