Passed
Push — master ( 99f62c...22c5d8 )
by Alex
07:13
created

getListOfSupportedRequestMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
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, http://aeon.su
12
 */
13
14
/**
15
 * Supported request types
16
 *
17
 * @author gdever
18
 */
19
class SupportedRequestMethods
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 . '"', -1));
49
        }
50
    }
51
}
52