src/UriHandler.php
public function uri($parameters = [], array $defaults = []): UriInterface
    {
        if (!$this->isCompiled()) {
            $this->compile();
        }

        $parameters = array_merge(
            $this->options,
            $defaults,
            $this->fetchOptions($parameters, $query)
        );

        foreach ($this->constrains as $key => $values) {
            if (empty($parameters[$key])) {
                throw new UriHandlerException("Unable to generate Uri, parameter `{$key}` is missing.");
            }
        }

        //Uri without empty blocks (pretty stupid implementation)
        $path = $this->interpolate($this->template, $parameters);

        //Uri with added prefix
        $uri = new Uri(($this->matchHost ? '' : $this->prefix) . trim($path, '/'));

        return empty($query) ? $uri : $uri->withQuery(http_build_query($query));
    }
public function uri($parameters = [], array $defaults = []): UriInterface
    {
        if (!$this->isCompiled()) {
            $this->compile();
        }

        $parameters = array_merge(
            $this->options,
            $defaults,
            $this->fetchOptions($parameters, $query)
        );

        foreach ($this->constrains as $key => $values) {
            if (empty($parameters[$key])) {
                throw new UriHandlerException("Unable to generate Uri, parameter `{$key}` is missing.");
            }
        }

        //Uri without empty blocks (pretty stupid implementation)
        $path = $this->interpolate($this->template, $parameters);

        //Uri with added prefix
        $uri = new Uri(($this->matchHost ? '' : $this->prefix) . trim($path, '/'));

        return empty($query) ? $uri : $uri->withQuery(http_build_query($query));
    }
public function uri ( $ parameters = [ ] , array $ defaults = [ ] ) : UriInterface { if ( ! $ this -> isCompiled ( ) ) { $ this -> compile ( ) ; } $ parameters = array_merge ( $ this -> options , $ defaults , $ this -> fetchOptions ( $ parameters , $ query ) ) ; foreach ( $ this -> constrains as $ key => $ values ) { if ( empty ( $ parameters [ $ key ] ) ) { throw new UriHandlerException ( "Unable to generate Uri, parameter `{$key}` is missing." ) ; } } //Uri without empty blocks (pretty stupid implementation) $ path = $ this -> interpolate ( $ this -> template , $ parameters ) ; //Uri with added prefix $ uri = new Uri ( ( $ this -> matchHost ? '' : $ this -> prefix ) . trim ( $ path , '/' ) ) ; return empty ( $ query ) ? $ uri : $ uri -> withQuery ( http_build_query ( $ query ) ) ; }
Generate Uri for a given parameters and default values.

@param array|\Traversable $parameters
@param array              $defaults
@return UriInterface
Generate Uri for a given parameters and default values .