Copied!

Represents a path template.

Templates use the syntax of the API platform; see the protobuf of HttpRule for details. A template consists of a sequence of literals, wildcards, and variable bindings, where each binding can have a sub-path. A string representation can be parsed into an instance of PathTemplate, which can then be used to perform matching and instantiation.

CloneableInstantiable
Methods
public __construct(?string $path = NULL)
 

PathTemplate constructor.

  • param string $path A path template string
  • throws \ValidationException When $path cannot be parsed into a valid PathTemplate
public __toString() : string
 
  • return string A string representation of the path template
public match(string $path)
 

Matches a fully qualified path template string.

  • param string $path A fully qualified path template string.
  • throws \ValidationException if path can't be matched to the template.
  • return array Array matching var names to binding values.
public matches(string $path)
 

Check if $path matches a resource string.

  • param string $path A resource string.
  • return bool
public render(array $bindings)
 

Renders a path template using the provided bindings.

  • param array $bindings An array matching var names to binding strings.
  • throws \ValidationException if a key isn't provided or if a sub-template can't be parsed.
  • return string A rendered representation of this path template.
Properties
private $resourceTemplate = NULL
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration