handlePhpError()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 4
crap 2
1
<?php
2
3
/**
4
 * This file is part of coisa/error-handler.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\ErrorHandler\Handler;
15
16
use CoiSA\ErrorHandler\Exception\ErrorException;
17
18
/**
19
 * Class ThrowErrorExceptionPhpErrorHandler
20
 *
21
 * @package CoiSA\ErrorHandler\Handler
22
 */
23
final class ThrowErrorExceptionPhpErrorHandler implements PhpErrorHandlerInterface
24
{
25
    /**
26
     * @param int    $code
27
     * @param string $message
28
     * @param string $filename
29
     * @param int    $line
30
     *
31
     * @throws ErrorException
32
     */
33 2
    public function handlePhpError(int $code, string $message, string $filename, int $line): void
34
    {
35 2
        if (!(\error_reporting() & $code)) {
36 1
            return;
37
        }
38
39 1
        throw new ErrorException($message, $code, $code, $filename, $line);
40
    }
41
}
42