CompanyLogMethodEnum   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 21
c 1
b 0
f 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 9 1
A fromValue() 0 9 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
}