$values Tag (without braces) => replacement value. * @return string */ public static function apply( string $text, array $values ): string { $replacements = array(); foreach ( $values as $tag => $value ) { $replacements[ '{' . $tag . '}' ] = (string) $value; } return strtr( $text, $replacements ); } }