Lines 100.00% 5 / 5
Methods 100.00% 1 / 1
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 fromChecked 100.00% 5 / 5 100.00% 1 / 1 1
11enum ColumnOperator: string
12{
13    /** Equality (`=`). */
14    case Eq = '=';
15
16    /** Inequality (`!=`). */
17    case NotEq = '!=';
18
19    /** Less than (`<`). */
20    case Lt = '<';
21
22    /** Less than or equal (`<=`). */
23    case LtEq = '<=';
24
25    /** Greater than (`>`). */
26    case Gt = '>';
27
28    /** Greater than or equal (`>=`). */
29    case GtEq = '>=';
30
31    /**
32     * Resolve a string to a case, failing fast on anything else.
33     *
34     * @param  string  $operator
35     * @return self
36     * @throws \InvalidArgumentException
37     */
38    public static function fromChecked(string $operator): self
39    {
40        return self::tryFrom($operator)
41            ?? self::tryFrom(strtoupper($operator))
42            ?? throw new \InvalidArgumentException(
43                "Invalid column comparison operator [{$operator}]. Expected one of: =, !=, <, <=, >, >=."
44            );
45    }
46}