1 | <?php |
||
20 | class FastRouteMiddleware implements MiddlewareInterface |
||
21 | { |
||
22 | /** |
||
23 | * Fast Route Dispatcher |
||
24 | * |
||
25 | * @var \FastRoute\Dispatcher |
||
26 | */ |
||
27 | protected $dispatcher; |
||
28 | |||
29 | /** |
||
30 | * Route not allowed Handler |
||
31 | * |
||
32 | * @var null|\Burzum\FastRouteMiddleware\Handler\NotAllowedHandlerInterface |
||
33 | */ |
||
34 | protected $notAllowedHandler; |
||
35 | |||
36 | /** |
||
37 | * Route not found Handler |
||
38 | * |
||
39 | * @var null|\Burzum\FastRouteMiddleware\Handler\NotFoundHandlerInterface |
||
40 | */ |
||
41 | protected $notFoundHandler; |
||
42 | |||
43 | /** |
||
44 | * Route Found Handler |
||
45 | * |
||
46 | * @var null|\Burzum\FastRouteMiddleware\Handler\FoundHandlerInterface |
||
47 | */ |
||
48 | protected $foundHandler; |
||
49 | |||
50 | /** |
||
51 | * Route Attribute for the Request |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $routeAttribute = 'route'; |
||
56 | |||
57 | /** |
||
58 | * Constructor |
||
59 | * |
||
60 | * @param \FastRoute\Dispatcher $dispatcher Fastroute Dispatcher |
||
61 | */ |
||
62 | 1 | public function __construct( |
|
63 | DispatcherInterface $dispatcher, |
||
64 | ?FoundHandlerInterface $foundHandler = null, |
||
65 | ?NotFoundHandlerInterface $notFoundHandler = null, |
||
66 | ?NotAllowedHandlerInterface $notAllowedHandler = null |
||
|
|||
67 | ) { |
||
68 | 1 | $this->dispatcher = $dispatcher; |
|
69 | 1 | $this->foundHandler = $foundHandler; |
|
70 | 1 | $this->notFoundHandler = $notFoundHandler; |
|
71 | 1 | $this->notAllowedHandler = $notFoundHandler; |
|
72 | 1 | } |
|
73 | |||
74 | /** |
||
75 | * Sets the route attribute name |
||
76 | * |
||
77 | * @param string $attributeName Attribute Name |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function setRouteAttribute(string $attributeName): self |
||
86 | |||
87 | /** |
||
88 | * Process an incoming server request and return a response, optionally |
||
89 | * delegating response creation to a handler. |
||
90 | * |
||
91 | * @param \Psr\Http\Message\ServerRequestInterface $request Request |
||
92 | * @param \Psr\Http\Server\RequestHandlerInterface $requestHandler Request Handler |
||
93 | * @return \Psr\Http\Message\ResponseInterface |
||
94 | */ |
||
95 | 1 | public function process(ServerRequestInterface $request, RequestHandlerInterface $requestHandler): ResponseInterface |
|
128 | |||
129 | /** |
||
130 | * Dispatches the Request URI |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | 1 | protected function dispatch(): array |
|
147 | } |
||
148 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.