Conditions | 6 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function beforeExecuteRoute(/** @scrutinizer ignore-unused */ Event $event, Dispatcher $dispatcher): bool |
||
22 | { |
||
23 | /** @var AdapterInterface $annotationsAdapter */ |
||
24 | $annotationsAdapter = $dispatcher->getDI()->get('annotations'); |
||
25 | $methodAnnotations = $annotationsAdapter->getMethod($dispatcher->getControllerClass(), |
||
26 | $dispatcher->getActionName() . 'Action'); |
||
27 | if ($methodAnnotations->has('Method')) { |
||
28 | $args = $methodAnnotations->get('Method')->getArguments(); |
||
29 | /** @var RequestInterface $request */ |
||
30 | $request = $dispatcher->getDI()->get('request'); |
||
31 | if ($request->isGet()) { |
||
32 | return in_array('GET', $args); |
||
33 | } |
||
34 | if ($request->isPost()) { |
||
35 | return in_array('POST', $args); |
||
36 | } |
||
37 | if ($request->isPut()) { |
||
38 | return in_array('PUT', $args); |
||
39 | } |
||
40 | if ($request->isDelete()) { |
||
41 | return in_array('DELETE', $args); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return true; |
||
46 | } |
||
47 | } |