| Conditions | 4 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4.0466 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | 10 | public function __invoke(Application $app, Request $request) |
|
| 15 | { |
||
| 16 | 10 | $app["request_context"]->setMethod("NOTAMETHOD"); |
|
| 17 | |||
| 18 | try { |
||
| 19 | 10 | $app["request_matcher"]->match($request->getPathInfo()); |
|
| 20 | $allow = []; // Should never get here |
||
| 21 | 10 | } catch (MethodNotAllowedException $e) { |
|
| 22 | 10 | $allow = array_filter($e->getAllowedMethods(), function ($method) { |
|
| 23 | 10 | return $method != "OPTIONS"; |
|
| 24 | 10 | }); |
|
| 25 | 10 | } catch (ResourceNotFoundException $e) { |
|
| 26 | $allow = []; // Should never get here |
||
| 27 | } |
||
| 28 | |||
| 29 | 10 | $app["request_context"]->setMethod("OPTIONS"); |
|
| 30 | |||
| 31 | 10 | if (count($allow) == 0) { |
|
| 32 | 1 | throw new NotFoundHttpException(); |
|
| 33 | } |
||
| 34 | |||
| 35 | 9 | return Response::create("", 204, ["Allow" => implode(",", $allow)]); |
|
| 36 | } |
||
| 37 | } |
||
| 38 |