ListenerAbstract   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A on() 0 6 1
A priority() 0 4 1
handle() 0 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