protected function _write($options, $defaults) {
		$template = $this->_template;
		$trimmed = true;
		$options += ['args' => ''];

		foreach (array_reverse($this->_keys, true) as $key) {
			$value =& $options[$key];
			$pattern = isset($this->_subPatterns[$key]) ? ":{$this->_subPatterns[$key]}" : '';
			$rpl = "{:{$key}{$pattern}}";
			$len = strlen($rpl) * -1;

			if ($trimmed && isset($defaults[$key]) && $value == $defaults[$key]) {
				if (substr($template, $len) == $rpl) {
					$template = rtrim(substr($template, 0, $len), '/');
					continue;
				}
			}
			if ($value === null) {
				$template = str_replace("/{$rpl}", '', $template);
				continue;
			}
			if ($key !== 'args') {
				$trimmed = false;
			}
			$template = str_replace($rpl, $value, $template);
		}
		return $template ?: '/';
	}
protected function _write($options, $defaults) {
		$template = $this->_template;
		$trimmed = true;
		$options += ['args' => ''];

		foreach (array_reverse($this->_keys, true) as $key) {
			$value =& $options[$key];
			$pattern = isset($this->_subPatterns[$key]) ? ":{$this->_subPatterns[$key]}" : '';
			$rpl = "{:{$key}{$pattern}}";
			$len = strlen($rpl) * -1;

			if ($trimmed && isset($defaults[$key]) && $value == $defaults[$key]) {
				if (substr($template, $len) == $rpl) {
					$template = rtrim(substr($template, 0, $len), '/');
					continue;
				}
			}
			if ($value === null) {
				$template = str_replace("/{$rpl}", '', $template);
				continue;
			}
			if ($key !== 'args') {
				$trimmed = false;
			}
			$template = str_replace($rpl, $value, $template);
		}
		return $template ?: '/';
	}
protected function _write ( $ options , $ defaults ) { $ template = $ this -> _template ; $ trimmed = true ; $ options += [ 'args' => '' ] ; foreach ( array_reverse ( $ this -> _keys , true ) as $ key ) { $ value = & $ options [ $ key ] ; $ pattern = isset ( $ this -> _subPatterns [ $ key ] ) ? ":{$this->_subPatterns[$key]}" : '' ; $ rpl = "{:{$key}{$pattern}}" ; $ len = strlen ( $ rpl ) * - 1 ; if ( $ trimmed && isset ( $ defaults [ $ key ] ) && $ value == $ defaults [ $ key ] ) { if ( substr ( $ template , $ len ) == $ rpl ) { $ template = rtrim ( substr ( $ template , 0 , $ len ) , '/' ) ; continue ; } } if ( $ value === null ) { $ template = str_replace ( "/{$rpl}" , '' , $ template ) ; continue ; } if ( $ key !== 'args' ) { $ trimmed = false ; } $ template = str_replace ( $ rpl , $ value , $ template ) ; } return $ template ? : '/' ; }
Writes a set of URL options to this route's template string.

@param array $options The options to write to this route, with defaults pre-merged.
@param array $defaults The default template options for this route (contains hard-coded
default values).
@return string Returns the route template string with option values inserted.
Writes a set of URL options to this route s template string .