ExceptionHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace yiicod\jobqueue\handlers;
4
5
use Exception;
6
use Yii;
7
8
/**
9
 * DaemonExceptionHandler
10
 *
11
 * @author Virchenko Maksim <[email protected]>
12
 */
13
class ExceptionHandler implements \Illuminate\Contracts\Debug\ExceptionHandler
14
{
15
    /**
16
     * DaemonExceptionHandler constructor.
17
     */
18
    public function __construct()
19
    {
20
        // automatically send every new message to available log routes
21
        Yii::getLogger()->flushInterval = 1;
22
    }
23
24
    /**
25
     * Report or log an exception.
26
     *
27
     * @param  \Exception $e
28
     */
29
    public function report(Exception $e)
30
    {
31
        Yii::error(sprintf("%s (%s : %s)\nStack trace:\n%s", $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()), 'jobqueue');
32
    }
33
34
    /**
35
     * Render an exception into an HTTP response.
36
     *
37
     * @param  \HttpRequest $request
38
     * @param  \Exception $e
39
     */
40
    public function render($request, Exception $e)
41
    {
42
        return;
43
    }
44
45
    /**
46
     * Render an exception to the console.
47
     *
48
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
49
     * @param  \Exception $e
50
     */
51
    public function renderForConsole($output, Exception $e)
52
    {
53
        return;
54
    }
55
}
56