src/UriBuilder.php
public function build($trailingSlash = false)
	{
		$result = '';
		
		foreach(preg_split("'(\\{(?:(?>[^\\{\\}]+)|(?R))+\\})'S", $this->uri, -1, PREG_SPLIT_DELIM_CAPTURE) as $part)
		{
			if(substr($part, 0, 1) == '{')
			{
				$result .= Uri::encode($this->path[substr($part, 1, -1)]);
			}
			else
			{
				$result .= $part;
			}
		}
		
		$result = $this->replaceParams($this->uri, $this->path);
		
		if($trailingSlash && substr($result, -1) != '/')
		{
			$uri = new Uri($result . '/');
		}
		else
		{
			$uri = new Uri($result);
		}
		
		if(!empty($this->query))
		{
			$uri = $uri->setQuery($this->query);
		}
		
		if($this->fragment !== NULL)
		{
			if(false === strpos($this->fragment, '{'))
			{
				$uri = $uri->setFragment($this->fragment);
			}
			else
			{
				$uri = $uri->setFragment($this->replaceParams($this->fragment, $this->path));
			}
		}
		
		return $uri;
	}
public function build($trailingSlash = false)
	{
		$result = '';
		
		foreach(preg_split("'(\\{(?:(?>[^\\{\\}]+)|(?R))+\\})'S", $this->uri, -1, PREG_SPLIT_DELIM_CAPTURE) as $part)
		{
			if(substr($part, 0, 1) == '{')
			{
				$result .= Uri::encode($this->path[substr($part, 1, -1)]);
			}
			else
			{
				$result .= $part;
			}
		}
		
		$result = $this->replaceParams($this->uri, $this->path);
		
		if($trailingSlash && substr($result, -1) != '/')
		{
			$uri = new Uri($result . '/');
		}
		else
		{
			$uri = new Uri($result);
		}
		
		if(!empty($this->query))
		{
			$uri = $uri->setQuery($this->query);
		}
		
		if($this->fragment !== NULL)
		{
			if(false === strpos($this->fragment, '{'))
			{
				$uri = $uri->setFragment($this->fragment);
			}
			else
			{
				$uri = $uri->setFragment($this->replaceParams($this->fragment, $this->path));
			}
		}
		
		return $uri;
	}
public function build ( $ trailingSlash = false ) { $ result = '' ; foreach ( preg_split ( "'(\\{(?:(?>[^\\{\\}]+)|(?R))+\\})'S" , $ this -> uri , - 1 , PREG_SPLIT_DELIM_CAPTURE ) as $ part ) { if ( substr ( $ part , 0 , 1 ) == '{' ) { $ result .= Uri :: encode ( $ this -> path [ substr ( $ part , 1 , - 1 ) ] ) ; } else { $ result .= $ part ; } } $ result = $ this -> replaceParams ( $ this -> uri , $ this -> path ) ; if ( $ trailingSlash && substr ( $ result , - 1 ) != '/' ) { $ uri = new Uri ( $ result . '/' ) ; } else { $ uri = new Uri ( $ result ) ; } if ( ! empty ( $ this -> query ) ) { $ uri = $ uri -> setQuery ( $ this -> query ) ; } if ( $ this -> fragment !== NULL ) { if ( false === strpos ( $ this -> fragment , '{' ) ) { $ uri = $ uri -> setFragment ( $ this -> fragment ) ; } else { $ uri = $ uri -> setFragment ( $ this -> replaceParams ( $ this -> fragment , $ this -> path ) ) ; } } return $ uri ; }
Build a URI from template and assigned parameters.

@param boolean $trailingSlash
@return Uri

@throws \OutOfBoundsException When at least one path parameter value is missing.
Build a URI from template and assigned parameters .