Lines
100.00%
6 / 6
Methods
100.00%
1 / 1
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| fromChecked | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 1 | ||
| 10 | enum WhereOperator: string | |
| 11 | { | |
| 12 | /** Equality (`=`). */ | |
| 13 | case Eq = '='; | |
| 14 | ||
| 15 | /** Inequality (`!=`). */ | |
| 16 | case NotEq = '!='; | |
| 17 | ||
| 18 | /** Less than (`<`). */ | |
| 19 | case Lt = '<'; | |
| 20 | ||
| 21 | /** Less than or equal (`<=`). */ | |
| 22 | case LtEq = '<='; | |
| 23 | ||
| 24 | /** Greater than (`>`). */ | |
| 25 | case Gt = '>'; | |
| 26 | ||
| 27 | /** Greater than or equal (`>=`). */ | |
| 28 | case GtEq = '>='; | |
| 29 | ||
| 30 | /** SQL `LIKE`. */ | |
| 31 | case Like = 'LIKE'; | |
| 32 | ||
| 33 | /** SQL `NOT LIKE`. */ | |
| 34 | case NotLike = 'NOT LIKE'; | |
| 35 | ||
| 36 | /** Membership in a list. */ | |
| 37 | case In = 'IN'; | |
| 38 | ||
| 39 | /** Exclusion from a list. */ | |
| 40 | case NotIn = 'NOT IN'; | |
| 41 | ||
| 42 | /** `IS` (rarely used directly; prefer `whereNull()`). */ | |
| 43 | case Is = 'IS'; | |
| 44 | ||
| 45 | /** `IS NOT` (rarely used directly; prefer `whereNotNull()`). */ | |
| 46 | case IsNot = 'IS NOT'; | |
| 47 | ||
| 48 | /** `BETWEEN` two values. */ | |
| 49 | case Between = 'BETWEEN'; | |
| 50 | ||
| 51 | /** `NOT BETWEEN` two values. */ | |
| 52 | case NotBetween = 'NOT BETWEEN'; | |
| 53 | ||
| 54 | /** `IS NULL`. */ | |
| 55 | case Null = 'NULL'; | |
| 56 | ||
| 57 | /** `IS NOT NULL`. */ | |
| 58 | case NotNull = 'NOT NULL'; | |
| 59 | ||
| 60 | /** | |
| 61 | * Resolve a string to a case, failing fast on anything else. | |
| 62 | * | |
| 63 | * @param string $operator | |
| 64 | * @return self | |
| 65 | * @throws \InvalidArgumentException | |
| 66 | */ | |
| 67 | public static function fromChecked(string $operator): self | |
| 68 | { | |
| 69 | return self::tryFrom($operator) | |
| 70 | ?? self::tryFrom(strtoupper($operator)) | |
| 71 | ?? throw new \InvalidArgumentException( | |
| 72 | "Invalid where operator [{$operator}]. Expected one of: =, !=, <, <=, >, >=, " | |
| 73 | . 'LIKE, NOT LIKE, IN, NOT IN, IS, IS NOT, BETWEEN, NOT BETWEEN, IS NULL, IS NOT NULL.' | |
| 74 | ); | |
| 75 | } | |
| 76 | } |