ListenerAbstract::handle()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
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