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

QB_CONDITION   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
ccs 5
cts 10
cp 0.5
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCase() 0 6 1
A name() 0 5 1
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
}