ChainedExceptionHandler::renderForConsole()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Nord\Lumen\ChainedExceptionHandler;
4
5
use Exception;
6
use Illuminate\Contracts\Debug\ExceptionHandler;
7
8
/**
9
 * Class ChainedExceptionHandler
10
 * @package Nord\Lumen\ChainedExceptionHandler
11
 */
12
class ChainedExceptionHandler implements ExceptionHandler
13
{
14
15
    /**
16
     * @var ExceptionHandler
17
     */
18
    private $primaryHandler;
19
20
    /**
21
     * @var ExceptionHandler[]
22
     */
23
    private $secondaryHandlers;
24
25
26
    /**
27
     * ChainedExceptionHandler constructor.
28
     *
29
     * @param ExceptionHandler   $primaryHandler
30
     * @param ExceptionHandler[] $secondaryHandlers (optional)
31
     */
32
    public function __construct(ExceptionHandler $primaryHandler, array $secondaryHandlers = [])
33
    {
34
        $this->primaryHandler    = $primaryHandler;
35
        $this->secondaryHandlers = $secondaryHandlers;
36
    }
37
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function report(Exception $e)
43
    {
44
        $this->primaryHandler->report($e);
45
46
        foreach ($this->secondaryHandlers as $handler) {
47
            $handler->report($e);
48
        }
49
    }
50
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function render($request, Exception $e)
56
    {
57
        return $this->primaryHandler->render($request, $e);
58
    }
59
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function renderForConsole($output, Exception $e)
65
    {
66
        $this->primaryHandler->renderForConsole($output, $e);
67
    }
68
69
}
70