public static function expand($template, array $variables)
{
if (strpos($template, '{') === false) {
return $template;
}
self::$variables = $variables;
return preg_replace_callback('/\\{([^\\}]+)\\}/', [UriTemplate::class, 'expandMatch'], $template);
}
/** * @dataProvider templateStrings * @test */ public function uriTemplatesAreExpandedCorrectly($templateString, array $variables, $expectedString) { $expandedTemplate = UriTemplate::expand($templateString, $variables); $this->assertEquals($expectedString, $expandedTemplate); }