CompanyLogMethodEnum::fromValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
namespace SimpleCMS\Company\Enums;
3
4
enum CompanyLogMethodEnum: int
5
{
6
7
    case OPTION = 0;
8
    case GET = 1;
9
    case POST = 2;
10
    case PUT = 3;
11
    case PATCH = 4;
12
    case DELETE = 5;
13
14
    public static function fromValue(int $value): self
15
    {
16
        return match ($value) {
17
            1 => self::GET,
18
            2 => self::POST,
19
            3 => self::PUT,
20
            4 => self::PATCH,
21
            5 => self::DELETE,
22
            default => self::GET
23
        };
24
    }
25
26
    public static function getValue(string $case): self
27
    {
28
        return match (strtoupper($case)) {
29
            'GET' => static::GET,
30
            'POST' => static::POST,
31
            'PUT' => static::PUT,
32
            'PATCH' => static::PATCH,
33
            'DELETE' => static::DELETE,
34
            default => static::OPTION
35
        };
36
    }
37
}