MethodNotAllowedException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Simply\Router\Exception;
4
5
/**
6
 * Exception that is thrown when the path matches, but the HTTP request method does not match any known route.
7
 * @author Riikka Kalliomäki <[email protected]>
8
 * @copyright Copyright (c) 2018-2019 Riikka Kalliomäki
9
 * @license http://opensource.org/licenses/mit-license.php MIT License
10
 */
11
class MethodNotAllowedException extends RoutingException
12
{
13
    /** @var string[] List of HTTP request methods that would be allowed */
14
    private $allowedMethods;
15
16
    /**
17
     * MethodNotAllowedException constructor.
18
     * @param string $message The exception message
19
     * @param string[] $allowedMethods List of HTTP request methods that are allowed
20
     */
21 2
    public function __construct(string $message, array $allowedMethods)
22
    {
23 2
        $this->allowedMethods = $allowedMethods;
24
25 2
        parent::__construct($message);
26 2
    }
27
28
    /**
29
     * Returns a list of allowed HTTP request methods.
30
     * @return string[] List of allowed HTTP request methods
31
     */
32 2
    public function getAllowedMethods(): array
33
    {
34 2
        return $this->allowedMethods;
35
    }
36
}
37