Total Complexity | 4 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
9 | final class MethodNotAllowed extends AbstractApiProblem |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $method; |
||
15 | |||
16 | /** |
||
17 | * @var string[] |
||
18 | */ |
||
19 | private $allowedMethods = []; |
||
20 | |||
21 | /** |
||
22 | * @param string $method, |
||
23 | * @param string[] $allowedMethods |
||
24 | */ |
||
25 | public function __construct(string $method, array $allowedMethods, string $detail = null, string $instance = null) |
||
26 | { |
||
27 | 2 | parent::__construct( |
|
28 | 'https://tools.ietf.org/html/rfc2616#section-10.4.6', |
||
29 | 2 | 405, |
|
30 | 2 | 'Method Not Allowed', |
|
31 | 2 | $detail, |
|
32 | 2 | $instance |
|
33 | ); |
||
34 | |||
35 | $this->method = $method; |
||
36 | $this->allowedMethods = $allowedMethods; |
||
37 | 2 | } |
|
38 | 2 | ||
39 | 2 | public function getHeaders(): array |
|
40 | { |
||
41 | return ['Allow' => implode(',', $this->allowedMethods)]; |
||
42 | } |
||
43 | |||
44 | 2 | public function getMethod(): string |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return string[] |
||
51 | */ |
||
52 | 2 | public function getAllowedMethods(): array |
|
55 | } |
||
56 | } |
||
57 |