Passed
Push — master ( 61ffee...578120 )
by Aleksandr
13:14
created

QB_CONDITION::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Aleksandr Drobotik <[email protected]>
5
 * @copyright 2023 Aleksandr Drobotik
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Drobotik\Eav\Enum;
11
12
use Drobotik\Eav\Exception\QueryBuilderException;
13
14
enum QB_CONDITION
15
{
16
    case AND;
17
    case OR;
18
19 1
    public function name() : string
20
    {
21 1
        return match ($this) {
22 1
            self::AND => "and",
23 1
            self::OR => "or"
24 1
        };
25
    }
26
27
    public static function getCase(string $slug)
28
    {
29
        return match($slug) {
30
            self::AND->name() => self::AND,
31
            self::OR->name() => self::OR,
32
            default => QueryBuilderException::unsupportedCondition($slug)
33
        };
34
    }
35
}