LightnCandy\Validator::operator PHP Method

operator() protected static method

Verify operators
protected static operator ( string $operator, array\arraystring | integer> &$context, arrayinteger | string | array> &$vars ) : boolean | integer | null
$operator string the operator string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
return boolean | integer | null Return true when invalid or detected
    protected static function operator($operator, &$context, &$vars)
    {
        switch ($operator) {
            case '#*':
                if (!$context['compile']) {
                    static::pushLeft($context);
                    $context['stack'][] = count($context['parsed'][0]);
                    static::pushStack($context, '#*', $vars);
                    array_unshift($context['inlinepartial'], '');
                }
                return static::inline($context, $vars);
            case '#>':
                if (!$context['compile']) {
                    static::pushLeft($context);
                    $context['stack'][] = count($context['parsed'][0]);
                    $vars[Parser::PARTIALBLOCK] = ++$context['usedFeature']['pblock'];
                    static::pushStack($context, '#>', $vars);
                    array_unshift($context['partialblock'], '');
                }
                return static::partial($context, $vars);
            case '>':
                return static::partial($context, $vars);
            case '^':
                if (!isset($vars[0][0])) {
                    if (!$context['flags']['else']) {
                        $context['error'][] = 'Do not support {{^}}, you should do compile with LightnCandy::FLAG_ELSE flag';
                        return;
                    } else {
                        return static::doElse($context, $vars);
                    }
                }
                static::doElseChain($context);
                if (static::isBlockHelper($context, $vars)) {
                    static::pushStack($context, '#', $vars);
                    return static::blockCustomHelper($context, $vars, true);
                }
                static::pushStack($context, '^', $vars);
                return static::invertedSection($context, $vars);
            case '/':
                $r = static::blockEnd($context, $vars);
                if ($r !== Token::POS_BACKFILL) {
                    array_pop($context['stack']);
                    array_pop($context['stack']);
                    array_pop($context['stack']);
                }
                return $r;
            case '#':
                static::doElseChain($context);
                static::pushStack($context, '#', $vars);
                if (static::isBlockHelper($context, $vars)) {
                    return static::blockCustomHelper($context, $vars);
                }
                return static::blockBegin($context, $vars);
        }
    }