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

EventDispatcherAwareBehavior::eventDispatcher()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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