HttpMethod::isValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Muzzle;
4
5
use MyCLabs\Enum\Enum;
6
7
/**
8
 * @method static HttpMethod CONNECT
9
 * @method static HttpMethod DELETE
10
 * @method static HttpMethod GET
11
 * @method static HttpMethod HEAD
12
 * @method static HttpMethod OPTIONS
13
 * @method static HttpMethod PATCH
14
 * @method static HttpMethod POST
15
 * @method static HttpMethod PUT
16
 * @method static HttpMethod TRACE
17
 */
18
class HttpMethod extends Enum
19
{
20
21
    const CONNECT = 'CONNECT';
22
    const DELETE = 'DELETE';
23
    const GET = 'GET';
24
    const HEAD = 'HEAD';
25
    const OPTIONS = 'OPTIONS';
26
    const PATCH = 'PATCH';
27
    const POST = 'POST';
28
    const PUT = 'PUT';
29
    const TRACE = 'TRACE';
30
31
    public function __construct(string $value)
32
    {
33
34
        parent::__construct(strtoupper($value));
35
    }
36
37
    public static function isValid($value)
38
    {
39
40
        return in_array(strtoupper($value), static::toArray(), true);
41
    }
42
}
43