EventDispatcherAwareBehavior   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0
lcom 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A useEventDispatcher() 0 4 1
A eventDispatcher() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Event;
6
7
trait EventDispatcherAwareBehavior
8
{
9
    /**
10
     * @var EventDispatcher|null
11
     */
12
    protected $dispatcher;
13
14
    public function useEventDispatcher(EventDispatcher $emitter): void
15
    {
16
        $this->dispatcher = $emitter;
17
    }
18
19
    public function eventDispatcher(): EventDispatcher
20
    {
21
        if ($this->dispatcher === null) {
22
            $this->dispatcher = new EventDispatcher(new PrioritizedListenerRegistry());
23
        }
24
25
        return $this->dispatcher;
26
    }
27
}
28