for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the PHP Generics package.
*
* @package Generics
*/
namespace Generics\Util;
* @author Maik Greubel <[email protected]>
trait Interpolator
{
* Interpolates context values into the message placeholders.
* @param string $message
* The message containing placeholders
* @param array $context
* The context array containing the replacers
* @return string The interpolated message
private static function interpolate($message, array $context = array()): string
$replace = array();
if ($context !== null) {
foreach ($context as $key => $val) {
$replace['{' . $key . '}'] = $val;
}
return strtr($message, $replace);