protected function parseInstructions($content, $instruction)
    {
        $twig    = new Twig_Environment(new Twig_Loader_String());
        $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]");
        foreach ($sources as $source) {
            $toReplace = $source;
            $source    = $this->clearCondition($source);
            if ($source === '') {
                return $content;
            }
            $variables    = $this->extractVariables($source);
            $renderParams = [];

            foreach (array_keys($variables) as $index => $key) {
                $localVariable                = 'var_' . $index;
                $source                       = str_replace($key, $localVariable, $source);
                $renderParams[$localVariable] = $variables[$key];
            }
            $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $toReplace], ['', '', $twig->render($source, $renderParams)], $content);
        }
        return $content;
    }
protected function parseInstructions($content, $instruction)
    {
        $twig    = new Twig_Environment(new Twig_Loader_String());
        $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]");
        foreach ($sources as $source) {
            $toReplace = $source;
            $source    = $this->clearCondition($source);
            if ($source === '') {
                return $content;
            }
            $variables    = $this->extractVariables($source);
            $renderParams = [];

            foreach (array_keys($variables) as $index => $key) {
                $localVariable                = 'var_' . $index;
                $source                       = str_replace($key, $localVariable, $source);
                $renderParams[$localVariable] = $variables[$key];
            }
            $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $toReplace], ['', '', $twig->render($source, $renderParams)], $content);
        }
        return $content;
    }
protected function parseInstructions ( $ content , $ instruction ) { $ twig = new Twig_Environment ( new Twig_Loader_String ( ) ) ; $ sources = $ this -> getStringsBetween ( $ content , "[[{$instruction}]]" , "[[/{$instruction}]]" ) ; foreach ( $ sources as $ source ) { $ toReplace = $ source ; $ source = $ this -> clearCondition ( $ source ) ; if ( $ source === '' ) { return $ content ; } $ variables = $ this -> extractVariables ( $ source ) ; $ renderParams = [ ] ; foreach ( array_keys ( $ variables ) as $ index => $ key ) { $ localVariable = 'var_' . $ index ; $ source = str_replace ( $ key , $ localVariable , $ source ) ; $ renderParams [ $ localVariable ] = $ variables [ $ key ] ; } $ content = str_replace ( [ "[[{$instruction}]]" , "[[/{$instruction}]]" , $ toReplace ] , [ '' , '' , $ twig -> render ( $ source , $ renderParams ) ] , $ content ) ; } return $ content ; }
parsing instructions in notification content

@param String $content
@param String $instruction
@return String
parsing instructions in notification content