RegisterException::isKillingAllowed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace BlueRegister\Events;
4
5
use BlueEvent\Event\BaseEvent;
6
7
class RegisterException extends BaseEvent
8
{
9
    /**
10
     * @var bool
11
     */
12
    protected static $allowKill = false;
13
14
    /**
15
     * Set var that allow to kill application if register exception is throwed away
16
     *
17
     * @param bool $allowKill
18
     */
19 1
    public static function allowKill($allowKill)
20
    {
21 1
        self::$allowKill = (bool)$allowKill;
22 1
    }
23
24
    /**
25
     * @return bool
26
     */
27 1
    public static function isKillingAllowed()
28
    {
29 1
        return self::$allowKill;
30
    }
31
32
    /**
33
     * Allow to kill application if register throw an exception
34
     *
35
     * @param string $eventName
36
     * @param array $parameters
37
     * @throws \Exception
38
     */
39 2
    public function __construct($eventName, array $parameters)
40
    {
41 2
        parent::__construct($eventName, $parameters);
42
43 2
        if (self::$allowKill) {
44 1
            throw new \RuntimeException('System killed by Register Exception. Unknown class: ' . $parameters[0]);
45
        }
46 1
    }
47
}
48