public static function substVars($val, $props = null) { $sbuf = ''; $i = 0; while (true) { $j = strpos($val, self::DELIM_START, $i); if ($j === false) { // no more variables if ($i == 0) { // this is a simple string return $val; } else { // add the tail string which contails no variables and return the result. $sbuf .= substr($val, $i); return $sbuf; } } else { $sbuf .= substr($val, $i, $j - $i); $k = strpos($val, self::DELIM_STOP, $j); if ($k === false) { // LoggerOptionConverter::substVars() has no closing brace. Opening brace return ''; } else { $j += self::DELIM_START_LEN; $key = substr($val, $j, $k - $j); // first try in System properties $replacement = Payone_Log4php_LoggerOptionConverter::getSystemProperty($key, null); // then try props parameter if ($replacement == null and $props !== null) { $replacement = @$props[$key]; } if (!empty($replacement)) { // Do variable substitution on the replacement string // such that we can solve "Hello ${x2}" as "Hello p1" // the where the properties are // x1=p1 // x2=${x1} $recursiveReplacement = Payone_Log4php_LoggerOptionConverter::substVars($replacement, $props); $sbuf .= $recursiveReplacement; } $i = $k + self::DELIM_STOP_LEN; } } } }