AirbrakeExceptionHandler   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A report() 0 8 4
A render() 0 4 1
A renderForConsole() 0 4 1
1
<?php
2
3
namespace adamtester\laravelairbrake\Handler;
4
5
use Exception;
6
use Illuminate\Contracts\Debug\ExceptionHandler;
7
use Illuminate\Contracts\Foundation\Application;
8
9
class AirbrakeExceptionHandler implements ExceptionHandler
10
{
11
    /**
12
     * @var
13
     */
14
    private $handler;
15
16
    /**
17
     * @var Application
18
     */
19
    private $app;
20
21
    public function __construct(ExceptionHandler $handler, Application $app)
22
    {
23
        $this->handler = $handler;
24
        $this->app = $app;
25
    }
26
27
    /**
28
     * Report or log an exception.
29
     *
30
     * @param \Exception $e
31
     *
32
     * @return void
33
     */
34
    public function report(Exception $e)
35
    {
36
        if (is_array(config('airbrake.ignore_environments')) && !in_array(app()->environment(), config('airbrake.ignore_environments')) && $this->handler->shouldReport($e)) {
0 ignored issues
show
Bug introduced by
The method shouldReport() does not exist on Illuminate\Contracts\Debug\ExceptionHandler. Did you maybe mean report()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
37
            $this->app['Airbrake\Instance']->notify($e);
38
        }
39
40
        return $this->handler->report($e);
41
    }
42
43
    /**
44
     * Render an exception into an HTTP response.
45
     *
46
     * @param \Symfony\Component\Console\Output\OutputInterface $output
0 ignored issues
show
Bug introduced by
There is no parameter named $output. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
47
     * @param \Exception                                        $e
48
     *
49
     * @return \Symfony\Component\HttpFoundation\Response
50
     */
51
    public function render($request, Exception $e)
52
    {
53
        return $this->handler->render($request, $e);
54
    }
55
56
    /**
57
     * Render an exception to the console.
58
     *
59
     * @param \Symfony\Component\Console\Output\OutputInterface $output
60
     * @param \Exception                                        $e
61
     *
62
     * @return void
63
     */
64
    public function renderForConsole($output, Exception $e)
65
    {
66
        return $this->handler->renderForConsole($output, $e);
67
    }
68
}
69