Passed
Push — main ( 290755...ff431f )
by Tan
02:31
created

NotFoundHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 7 2
1
<?php
2
3
namespace CSlant\Blog\Core\Exceptions;
4
5
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6
use Illuminate\Http\JsonResponse;
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Http\Response;
9
use Throwable;
10
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
11
12
class NotFoundHandler extends ExceptionHandler
13
{
14
    public function render($request, Throwable $e): Response|JsonResponse|RedirectResponse|\Symfony\Component\HttpFoundation\Response
15
    {
16
        if ($e instanceof NotFoundHttpException) {
17
            return redirect('https://cslant.com/not-found', 301);
18
        }
19
20
        return parent::render($request, $e);
21
    }
22
}
23