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

NotFoundHandler::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 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