LightnCandy\Validator::doElse PHP Method

doElse() protected static method

Return 1 or larger number when else token detected
protected static doElse ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : integer
$context array\arraystring | integer>
$vars arrayinteger | string | array>
return integer Return 1 or larger number when else token detected
    protected static function doElse(&$context, $vars)
    {
        if ($context['level'] == 0) {
            $context['error'][] = '{{else}} only valid in if, unless, each, and #section context';
        }
        if (isset($vars[1][0])) {
            $token = $context['currentToken'];
            $context['currentToken'][Token::POS_RSPACE] = "{{#{$vars[1][0]} " . preg_replace('/^\\s*else\\s+' . $vars[1][0] . '\\s*/', '', $token[Token::POS_INNERTAG]) . '}}' . $context['currentToken'][Token::POS_RSPACE];
            array_unshift($context['elselvl'][0], $vars[1][0]);
            $context['elsechain'] = true;
        }
        return ++$context['usedFeature']['else'];
    }