Total Complexity | 8 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class MethodNegotiator implements MethodNegotiatorInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var array<string> |
||
13 | */ |
||
14 | private $allowMethods; |
||
15 | |||
16 | /** |
||
17 | * @param array<string> $allowMethods |
||
18 | */ |
||
19 | 4 | public function __construct(array $allowMethods) |
|
24 | } |
||
25 | 4 | } |
|
26 | |||
27 | 3 | public function negotiate(ServerRequestInterface $request): bool |
|
28 | { |
||
29 | 3 | if ('' === $method = $request->getHeaderLine(self::HEADER)) { |
|
30 | 1 | return false; |
|
31 | } |
||
32 | |||
33 | 2 | foreach ($this->allowMethods as $allowMethod) { |
|
34 | 2 | if ($allowMethod === $method) { |
|
35 | 2 | return true; |
|
36 | } |
||
37 | } |
||
38 | |||
39 | 1 | return false; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return array<string> |
||
44 | */ |
||
45 | 1 | public function getAllowedMethods(): array |
|
48 | } |
||
49 | |||
50 | 4 | private function addAllowMethod(string $allowMethod): void |
|
55 |