You are here

private function ConsoleLogger::interpolate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Logger/ConsoleLogger.php \Symfony\Component\Console\Logger\ConsoleLogger::interpolate()

Interpolates context values into the message placeholders.

@author PHP Framework Interoperability Group

Parameters

string $message:

array $context:

Return value

string

1 call to ConsoleLogger::interpolate()
ConsoleLogger::log in vendor/symfony/console/Logger/ConsoleLogger.php
Logs with an arbitrary level.

File

vendor/symfony/console/Logger/ConsoleLogger.php, line 106

Class

ConsoleLogger
PSR-3 compliant console logger.

Namespace

Symfony\Component\Console\Logger

Code

private 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);
}