/** * Format a URI Query component according to the Formatter properties * * @param UriInterface|Uri $uri * * @return string */ protected function formatQuery($uri) { $query = $this->formatUriPart(new Query($uri->getQuery())); if ($this->preserveQuery || '' !== $query) { $query = '?' . $query; } return $query; }
/** * Format a Interfaces\Schemes\Uri according to the Formatter properties * * @param Uri|UriInterface $uri * * @return string */ protected function formatUri($uri) { $scheme = $uri->getScheme(); if ('' !== $scheme) { $scheme .= ':'; } $query = $this->formatUriPart(new Query($uri->getQuery())); if ('' !== $query) { $query = '?' . $query; } $fragment = $uri->getFragment(); if ('' !== $fragment) { $fragment = '#' . $fragment; } $auth = $this->formatAuthority($uri); return $scheme . $auth . $this->formatPath($uri->getPath(), $auth) . $query . $fragment; }