Handler::sendEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Exceptions;
4
5
use Exception;
6
use App\Mail\ExceptionOccurred;
7
use Illuminate\Support\Facades\Mail;
8
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
9
10
class Handler extends ExceptionHandler
11
{
12
    /**
13
     * A list of the exception types that are not reported.
14
     *
15
     * @var array
16
     */
17
    protected $dontReport = [
18
        //
19
    ];
20
21
    /**
22
     * A list of the inputs that are never flashed for validation exceptions.
23
     *
24
     * @var array
25
     */
26
    protected $dontFlash = [
27
        'password',
28
        'password_confirmation',
29
    ];
30
31
    /**
32
     * Report or log an exception.
33
     *
34
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
35
     *
36
     * @param  \Exception  $exception
37
     * @return void
38
     */
39
    public function report(Exception $exception)
40
    {
41
        if (app()->environment() === 'production' && $this->shouldReport($exception)) {
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        if (app()->/** @scrutinizer ignore-call */ environment() === 'production' && $this->shouldReport($exception)) {
Loading history...
42
            $this->sendEmail($exception);
43
        }
44
45
        parent::report($exception);
46
    }
47
48
    /**
49
     * Render an exception into an HTTP response.
50
     *
51
     * @param  \Illuminate\Http\Request  $request
52
     * @param  \Exception  $exception
53
     * @return \Illuminate\Http\Response
54
     */
55
    public function render($request, Exception $exception)
56
    {
57
        return parent::render($request, $exception);
58
    }
59
60
    /**
61
     * Send an email to the administrator with the exception.
62
     *
63
     * @param  \Exception  $exception
64
     * @return void
65
     */
66
    public function sendEmail(Exception $exception)
67
    {
68
        Mail::to(config('benficalive.administrator_email'))
69
            ->send(new ExceptionOccurred($exception));
70
    }
71
}
72