for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Hyperized\Benchmark\Generic;
class Utility
{
/**
* @param string $string
* @param array $variables
*
* @return mixed
* Sourced: https://stackoverflow.com/a/17372566/1757763
*/
public static function format(string $string, array $variables)
$string = \preg_replace_callback('#\{\}#', function () {
static $i = 0;
return '{' . ($i++) . '}';
}, $string);
return \str_replace(
\array_map(function ($k) {
return '{' . $k . '}';
}, \array_keys($variables)), \array_values($variables), $string
);
}