protected function CommandUnishTestCase::interpolate

master CommandUnishTestCase.php protected CommandUnishTestCase::interpolate($message, array $context)
1 call to CommandUnishTestCase::interpolate()

File

tests/Unish/CommandUnishTestCase.php, line 412

Namespace

Unish

Class

CommandUnishTestCase

Code

protected function interpolate($message, array $context) {
  // build a replacement array with braces around the context keys
  $replace = array();
  foreach ($context as $key => $val) {
    if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
      $replace[sprintf('{%s}', $key)] = $val;
    }
  }
  // interpolate replacement values into the message and return
  return strtr($message, $replace);
}