| Total Complexity | 3 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class ExpectJsonOrThrow |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Handle an incoming request. |
||
| 20 | * |
||
| 21 | * @param Closure(Request): Response $next |
||
| 22 | */ |
||
| 23 | public function handle(Request $request, Closure $next): Response |
||
| 24 | { |
||
| 25 | if ($request->expectsJson()) { |
||
| 26 | return $next($request); |
||
| 27 | } |
||
| 28 | |||
| 29 | throw $this->throwable(); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Retrieve the Throwable instance to throw. |
||
| 34 | */ |
||
| 35 | protected function throwable(): Throwable |
||
| 38 | } |
||
| 39 | } |
||
| 40 |