Completed
Push — master ( 9832d4...95b345 )
by Dusan
01:27
created

BlockingErrorHandler::setTerminateLevelMask()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file is part of the error-handling package.
4
 *
5
 * Copyright (c) Dusan Vejin
6
 *
7
 * For full copyright and license information, please refer to the LICENSE file,
8
 * located at the package root folder.
9
 */
10
11
declare(strict_types=1);
12
13
namespace WeCodeIn\ErrorHandling\Handler;
14
15
use ErrorException;
16
use Throwable;
17
18
final class BlockingErrorHandler extends AbstractErrorHandler
19
{
20
    protected $terminateLevelMask = E_ALL;
21
22 2
    public function setTerminateLevelMask(int $terminateLevelMask) : BlockingErrorHandler
23
    {
24 2
        $this->terminateLevelMask = $terminateLevelMask;
25 2
        return $this;
26
    }
27
28 1
    protected function handle(Throwable $throwable)
29
    {
30 1
        $this->process($throwable);
31
32 1
        if ($this->shouldTerminate($throwable)) {
33
            exit(1);
34
        }
35 1
    }
36
37 1
    protected function shouldTerminate(Throwable $throwable) : bool
38
    {
39 1
        return $throwable instanceof ErrorException &&
0 ignored issues
show
Bug introduced by
The class ErrorException does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
40 1
            $throwable->getSeverity() & $this->terminateLevelMask;
41
    }
42
}
43