public function getPathParameter($name, $default = null) {

		// lazy initialization of parameters

		if(empty($this->pathParameters) && !is_null($this->placeholders)) {

			// collect all placeholder names

			$names = array_keys($this->placeholders);

			// extract values

			if(preg_match('~' . $this->match . '~', ltrim(Request::createFromGlobals()->getPathInfo(), '/'), $values)) {

				array_shift($values);

				// if not all parameters are set, try to fill up with defaults

				$offset = count($values);

				if($offset < count($names)) {
					
					while($offset < count($names)) {
						if(isset($this->placeholders[$names[$offset]]['default'])) {
							$values[] = $this->placeholders[$names[$offset]]['default'];
						}
						++$offset;
					}
				}

				// only set parameters when count of placeholders matches count of values, that can be evaluated

				if(count($values) === count($names)) {
					$this->pathParameters = array_combine($names, $values);
				}
			}

		}

		$name = strtolower($name);

		if(isset($this->pathParameters[$name])) {

			// both bool false and null are returned as null

			if($this->pathParameters[$name] === false || is_null($this->pathParameters[$name])) {
				return null;
			}

			return $this->pathParameters[$name];
		}

		return $default;

	}
public function getPathParameter($name, $default = null) {

		// lazy initialization of parameters

		if(empty($this->pathParameters) && !is_null($this->placeholders)) {

			// collect all placeholder names

			$names = array_keys($this->placeholders);

			// extract values

			if(preg_match('~' . $this->match . '~', ltrim(Request::createFromGlobals()->getPathInfo(), '/'), $values)) {

				array_shift($values);

				// if not all parameters are set, try to fill up with defaults

				$offset = count($values);

				if($offset < count($names)) {
					
					while($offset < count($names)) {
						if(isset($this->placeholders[$names[$offset]]['default'])) {
							$values[] = $this->placeholders[$names[$offset]]['default'];
						}
						++$offset;
					}
				}

				// only set parameters when count of placeholders matches count of values, that can be evaluated

				if(count($values) === count($names)) {
					$this->pathParameters = array_combine($names, $values);
				}
			}

		}

		$name = strtolower($name);

		if(isset($this->pathParameters[$name])) {

			// both bool false and null are returned as null

			if($this->pathParameters[$name] === false || is_null($this->pathParameters[$name])) {
				return null;
			}

			return $this->pathParameters[$name];
		}

		return $default;

	}
public function getPathParameter ( $ name , $ default = null ) { // lazy initialization of parameters if ( empty ( $ this -> pathParameters ) && ! is_null ( $ this -> placeholders ) ) { // collect all placeholder names $ names = array_keys ( $ this -> placeholders ) ; // extract values if ( preg_match ( '~' . $ this -> match . '~' , ltrim ( Request :: createFromGlobals ( ) -> getPathInfo ( ) , '/' ) , $ values ) ) { array_shift ( $ values ) ; // if not all parameters are set, try to fill up with defaults $ offset = count ( $ values ) ; if ( $ offset < count ( $ names ) ) { while ( $ offset < count ( $ names ) ) { if ( isset ( $ this -> placeholders [ $ names [ $ offset ] ] [ 'default' ] ) ) { $ values [ ] = $ this -> placeholders [ $ names [ $ offset ] ] [ 'default' ] ; } ++ $ offset ; } } // only set parameters when count of placeholders matches count of values, that can be evaluated if ( count ( $ values ) === count ( $ names ) ) { $ this -> pathParameters = array_combine ( $ names , $ values ) ; } } } $ name = strtolower ( $ name ) ; if ( isset ( $ this -> pathParameters [ $ name ] ) ) { // both bool false and null are returned as null if ( $ this -> pathParameters [ $ name ] === false || is_null ( $ this -> pathParameters [ $ name ] ) ) { return null ; } return $ this -> pathParameters [ $ name ] ; } return $ default ; }
get path parameter

@param string $name
@param string $default

@return string
get path parameter