JmesPath\TreeCompiler::visit_comparator PHP Method

visit_comparator() private method

private visit_comparator ( array $node )
$node array
    private function visit_comparator(array $node)
    {
        $value = $this->makeVar('val');
        $a = $this->makeVar('left');
        $b = $this->makeVar('right');
        $this->write('// Visiting comparator node')->write('%s = $value;', $value)->dispatch($node['children'][0])->write('%s = $value;', $a)->write('$value = %s;', $value)->dispatch($node['children'][1])->write('%s = $value;', $b);
        if ($node['value'] == '==') {
            $this->write('$value = Utils::isEqual(%s, %s);', $a, $b);
        } elseif ($node['value'] == '!=') {
            $this->write('$value = !Utils::isEqual(%s, %s);', $a, $b);
        } else {
            $this->write('$value = (is_int(%s) || is_float(%s)) && (is_int(%s) || is_float(%s)) && %s %s %s;', $a, $a, $b, $b, $a, $node['value'], $b);
        }
        return $this;
    }