LightnCandy\Token::setDelimiter PHP Method

setDelimiter() public static method

Setup delimiter by default or provided string
public static setDelimiter ( array\arraystring | integer> &$context, string | null $left = null, string | null $right = null )
$context array\arraystring | integer>
$left string | null left string of a token
$right string | null right string of a token
    public static function setDelimiter(&$context, $left = null, $right = null)
    {
        if ($left === null) {
            $left = $context['delimiters'][0];
        }
        if ($right === null) {
            $right = $context['delimiters'][1];
        }
        if (preg_match('/=/', "{$left}{$right}")) {
            $context['error'][] = "Can not set delimiter contains '=' , you try to set delimiter as '{$left}' and '{$right}'.";
            return;
        }
        $context['tokens']['startchar'] = substr($left, 0, 1);
        $context['tokens']['left'] = $left;
        $context['tokens']['right'] = $right;
        $rawcount = $context['rawblock'] ? '{2}' : ($context['flags']['rawblock'] ? '{0,2}' : '?');
        $left = preg_quote($left);
        $right = preg_quote($right);
        $context['tokens']['search'] = "/^(.*?)(\\s*)({$left})(~?)(\\{{$rawcount})\\s*([\\^#\\/!&>\\*]{0,2})(.*?)\\s*(\\}{$rawcount})(~?)({$right})(\\s*)(.*)\$/s";
    }