RegisterException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 2
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A allowKill() 0 3 1
A isKillingAllowed() 0 3 1
A __construct() 0 6 2
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