Neos\Flow\Http\UriTemplate::expand PHP Метод

expand() публичный статический Метод

Expand the template string using the supplied variables
public static expand ( string $template, array $variables ) : string
$template string URI template to expand
$variables array variables to use with the expansion
Результат string
    public static function expand($template, array $variables)
    {
        if (strpos($template, '{') === false) {
            return $template;
        }
        self::$variables = $variables;
        return preg_replace_callback('/\\{([^\\}]+)\\}/', [UriTemplate::class, 'expandMatch'], $template);
    }

Usage Example

 /**
  * @dataProvider templateStrings
  * @test
  */
 public function uriTemplatesAreExpandedCorrectly($templateString, array $variables, $expectedString)
 {
     $expandedTemplate = UriTemplate::expand($templateString, $variables);
     $this->assertEquals($expectedString, $expandedTemplate);
 }