public static function fillPlaceholders(string $message, array $context)
    {
        $message = (string)$message;
        foreach ($context as $key => $value)
        {
            $placeholder = '{' . $key . '}';
            $strval = null;
            $pos = 0;
            while (($pos = strpos($message, $placeholder, $pos)) !== false)
            {
                $strval = $strval ?: WF::str($value);
                $message = 
                    substr($message, 0, $pos) 
                    . $strval 
                    . substr($message, $pos + strlen($placeholder));
                $pos = $pos + strlen($strval);
            }
        }
        return $message;
    }
public static function fillPlaceholders(string $message, array $context)
    {
        $message = (string)$message;
        foreach ($context as $key => $value)
        {
            $placeholder = '{' . $key . '}';
            $strval = null;
            $pos = 0;
            while (($pos = strpos($message, $placeholder, $pos)) !== false)
            {
                $strval = $strval ?: WF::str($value);
                $message = 
                    substr($message, 0, $pos) 
                    . $strval 
                    . substr($message, $pos + strlen($placeholder));
                $pos = $pos + strlen($strval);
            }
        }
        return $message;
    }
public static function fillPlaceholders ( string $ message , array $ context ) { $ message = ( string ) $ message ; foreach ( $ context as $ key => $ value ) { $ placeholder = '{' . $ key . '}' ; $ strval = null ; $ pos = 0 ; while ( ( $ pos = strpos ( $ message , $ placeholder , $ pos ) ) !== false ) { $ strval = $ strval ? : WF :: str ( $ value ) ; $ message = substr ( $ message , 0 , $ pos ) . $ strval . substr ( $ message , $ pos + strlen ( $ placeholder ) ) ; $ pos = $ pos + strlen ( $ strval ) ; } } return $ message ; }
Fill the place holders in the message with values from the context array
@param string $message The message to format. Any {var} placeholders will be replaced
with a value from the context array.
@param array $context Contains the values to replace the placeholders with.
@return string The message with placeholders replaced
Fill the place holders in the message with values from the context array