Pico::getPageUrl PHP Method

getPageUrl() public method

Returns the URL to a given page
public getPageUrl ( string $page, array | string $queryData = null ) : string
$page string identifier of the page to link to
$queryData array | string either an array containing properties to create a URL-encoded query string from, or a already encoded string
return string URL
    public function getPageUrl($page, $queryData = null)
    {
        if (is_array($queryData)) {
            $queryData = http_build_query($queryData, '', '&');
        } elseif ($queryData !== null && !is_string($queryData)) {
            throw new InvalidArgumentException('Argument 2 passed to ' . get_called_class() . '::getPageUrl() must be of the type array or string, ' . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given');
        }
        if (!empty($queryData)) {
            $page = !empty($page) ? $page : 'index';
            $queryData = $this->isUrlRewritingEnabled() ? '?' . $queryData : '&' . $queryData;
        }
        if (empty($page)) {
            return $this->getBaseUrl() . $queryData;
        } elseif (!$this->isUrlRewritingEnabled()) {
            return $this->getBaseUrl() . '?' . rawurlencode($page) . $queryData;
        } else {
            return $this->getBaseUrl() . implode('/', array_map('rawurlencode', explode('/', $page))) . $queryData;
        }
    }