Completed
Push — master ( 014f54...e2e99c )
by Frank
01:08
created

EventDispatcherAwareBehavior   A

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
lcom 1
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

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