src/MacroProcessor.php
public function process(string $string, int $strategy = EnumMacroProcessStorategy::STRATEGY_LAST)
    {
        // find and replce macro
        $ret = $string;
        $replace_exists = false;
        $keyword_list = self::findMacroKeywords($ret);
        foreach($keyword_list as $keyword){
            $replace = $this->callHandlers($keyword, $strategy);
            if ($replace !== null){
                $replace_exists |= $this->checkIfReplaceIncludeMacro($replace);
                $ret = str_replace("%$keyword%",$replace,$ret);
            }
        }
        
        // call recursive if possibly macro code found.
        return $replace_exists ? $this->process($ret, $strategy) : $ret;
    }
public function process(string $string, int $strategy = EnumMacroProcessStorategy::STRATEGY_LAST)
    {
        // find and replce macro
        $ret = $string;
        $replace_exists = false;
        $keyword_list = self::findMacroKeywords($ret);
        foreach($keyword_list as $keyword){
            $replace = $this->callHandlers($keyword, $strategy);
            if ($replace !== null){
                $replace_exists |= $this->checkIfReplaceIncludeMacro($replace);
                $ret = str_replace("%$keyword%",$replace,$ret);
            }
        }
        
        // call recursive if possibly macro code found.
        return $replace_exists ? $this->process($ret, $strategy) : $ret;
    }
public function process ( string $ string , int $ strategy = EnumMacroProcessStorategy :: STRATEGY_LAST ) { // find and replce macro $ ret = $ string ; $ replace_exists = false ; $ keyword_list = self :: findMacroKeywords ( $ ret ) ; foreach ( $ keyword_list as $ keyword ) { $ replace = $ this -> callHandlers ( $ keyword , $ strategy ) ; if ( $ replace !== null ) { $ replace_exists |= $ this -> checkIfReplaceIncludeMacro ( $ replace ) ; $ ret = str_replace ( "%$keyword%" , $ replace , $ ret ) ; } } // call recursive if possibly macro code found. return $ replace_exists ? $ this -> process ( $ ret , $ strategy ) : $ ret ; }
Expand string by macro keyword

@param string $string
@param int $strategy

@return string
Expand string by macro keyword