Passed
Push — master ( a4ddd3...82bd79 )
by Alex
06:44
created

SuppportedRequestMethods   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 1
f 0
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateRequestMethod() 0 4 2
A getListOfSupportedRequestMethods() 0 9 1
1
<?php
2
declare(strict_types = 1);
3
namespace Mezon\Router;
4
5
/**
6
 * Class SimpleRouter
7
 *
8
 * @package Router
9
 * @author Dodonov A.A.
10
 * @version v.1.0 (2021/09/27)
11
 * @copyright Copyright (c) 2021, aeon.org
12
 */
13
14
/**
15
 * Supported request types
16
 *
17
 * @author gdever
18
 */
19
class SuppportedRequestMethods
20
{
21
22
    /**
23
     * Method returns a list of supported request methods
24
     *
25
     * @return string[] list of supported request methods
26
     */
27
    public static function getListOfSupportedRequestMethods(): array
28
    {
29
        return [
30
            'GET',
31
            'POST',
32
            'PUT',
33
            'DELETE',
34
            'OPTION',
35
            'PATCH'
36
        ];
37
    }
38
39
    /**
40
     * Method validates request method
41
     *
42
     * @param string $requestMethod
43
     *            HTTP request method
44
     */
45
    public static function validateRequestMethod(string $requestMethod): void
46
    {
47
        if (!in_array($requestMethod, static::getListOfSupportedRequestMethods())) {
48
            throw (new \Exception('Unsupported request method: "' . $requestMethod . '"'));
49
        }
50
    }
51
}
52