Ejemplo n.º 1
0
 /**
  * Reverse resolves a route URL pattern by interpolating provided
  * values into their placeholders if required.
  *
  * @param string $identifier A string declaring an unique route identifier.
  * @param array  $parameters An associative array of parameter values. The array key
  *                           must correspond with a placeholder. The value can only store
  *                           alphanumeric strings or integers.
  * @param array  $query      An associative array which specifies values for an query string appended to the
  *                           reversed constructed URI.
  *
  * @return string Returns a string representing the URI of the specified route. The string
  *                also has any given parameters interpolated. If an array for a query is provided
  *                it's also appended.
  */
 public function reverse(string $identifier, array $parameters = [], array $query = []) : string
 {
     $haystack = $this->collection->fetch($identifier)->interpolate($parameters);
     if ($query) {
         $haystack .= '?' . http_build_query($query);
     }
     return $haystack;
 }