Conditions | 2 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
30 | public function handle(Request $request, Closure $next) |
||
31 | { |
||
32 | // In case the request was sent by Api Tester and route info is wanted |
||
33 | // we will halt the request and output route information instead. |
||
34 | if ($request->header('X-Api-Tester') === static::ROUTE_INFO) { |
||
35 | |||
36 | // Laravel 5.1 event |
||
37 | $this->events->listen('router.matched', [$this, 'handleMatchedRoute']); |
||
38 | |||
39 | // Laravel 5.2 event |
||
40 | $this->events->listen(RouteMatched::class, |
||
41 | function (RouteMatched $event) { |
||
42 | $this->handleMatchedRoute($event->route); |
||
43 | }); |
||
44 | } |
||
45 | |||
46 | return $next($request); |
||
47 | } |
||
48 | |||
59 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.