TriggerErrorHandler::__construct()   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
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @codingStandardsIgnoreStart
4
 *
5
 * @author       Barney Hanlon <[email protected]>
6
 * @copyright    Barney Hanlon 2017
7
 * @license      https://opensource.org/licenses/MIT
8
 *
9
 * @codingStandardsIgnoreEnd
10
 */
11
12
namespace Shrikeh\GuzzleMiddleware\TimerLogger\Handler\ExceptionHandler;
13
14
use Exception;
15
16
/**
17
 * Class ExceptionHandlerInterface.
18
 */
19
final class TriggerErrorHandler implements ExceptionHandlerInterface
20
{
21
    /**
22
     * @var int
23
     */
24
    private $errorLevel;
25
26
    /**
27
     * TriggerErrorHandler constructor.
28
     *
29
     * @param int $errorLevel the desired error level of exceptions
30
     */
31
    public function __construct($errorLevel = E_USER_NOTICE)
32
    {
33
        $this->errorLevel = $errorLevel;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function handle(Exception $e)
40
    {
41
        trigger_error($e->getMessage(), $this->errorLevel);
42
    }
43
}
44