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

EventDispatcherAwareBehavior::useEventDispatcher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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