* @license MIT */ declare(strict_types=1); namespace BitBadger\PDODocument; /** * The types of logical operations allowed for JSON fields */ enum Op { /** Equals (=) */ case EQ; /** Greater Than (>) */ case GT; /** Greater Than or Equal To (>=) */ case GE; /** Less Than (<) */ case LT; /** Less Than or Equal To (<=) */ case LE; /** Not Equal to (<>) */ case NE; /** Between (BETWEEN) */ case BT; /** Exists (IS NOT NULL) */ case EX; /** Does Not Exist (IS NULL) */ case NEX; /** * Get the SQL representation of this operator * * @return string The operator to use in SQL statements */ public function toSQL(): string { return match ($this) { Op::EQ => "=", Op::GT => ">", Op::GE => ">=", Op::LT => "<", Op::LE => "<=", Op::NE => "<>", Op::BT => "BETWEEN", Op::EX => "IS NOT NULL", Op::NEX => "IS NULL", }; } }