protected function interpolateContext(string $format, array $context = []): string {
        $final = preg_replace_callback('/{([^\s][^}]+[^\s]?)}/', function ($matches) use ($context) {
            $field = trim($matches[1], '{}');
            if (array_key_exists($field, $context)) {
                return $context[$field];
            } else {
                return $matches[1];
            }
        }, $format);
        return $final;
    }
protected function interpolateContext(string $format, array $context = []): string {
        $final = preg_replace_callback('/{([^\s][^}]+[^\s]?)}/', function ($matches) use ($context) {
            $field = trim($matches[1], '{}');
            if (array_key_exists($field, $context)) {
                return $context[$field];
            } else {
                return $matches[1];
            }
        }, $format);
        return $final;
    }
protected function interpolateContext ( string $ format , array $ context = [ ] ) : string { $ final = preg_replace_callback ( '/{([^\s][^}]+[^\s]?)}/' , function ( $ matches ) use ( $ context ) { $ field = trim ( $ matches [ 1 ] , '{}' ) ; if ( array_key_exists ( $ field , $ context ) ) { return $ context [ $ field ] ; } else { return $ matches [ 1 ] ; } } , $ format ) ; return $ final ; }
Interpolate contexts into messages containing bracket-wrapped format strings.

@param string $format
@param array $context optional. array of key-value pairs to replace into the format.
@return string
Interpolate contexts into messages containing bracket - wrapped format strings .