ListenerAbstract::priority()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace yiicod\listener\components\listeners;
4
5
use yii\base\Event;
6
7
abstract class ListenerAbstract implements ListenerInterface
8
{
9
    /**
10
     * @var Event
11
     */
12
    protected $event;
13
14
    /**
15
     * Call this on trigger event. Method should create object instance and call handle.
16
     *
17
     * @param Event $event
18
     */
19
    public static function on($event)
20
    {
21
        $class = get_called_class();
22
        $object = new $class($event);
23
        $object->handle($event);
24
    }
25
26
    /**
27
     * Return priority
28
     *
29
     * @return int
30
     */
31
    public static function priority(): int
32
    {
33
        return 10;
34
    }
35
36
    /**
37
     * Call on event method
38
     *
39
     * @param $event
40
     */
41
    abstract public function handle($event);
42
}
43