Completed
Pull Request — master (#1028)
by
unknown
13:06
created

EventDispatcherAwareTrait::getEventDispatcher()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace League\OAuth2\Server\Event;
4
5
use Psr\EventDispatcher\EventDispatcherInterface;
6
7
trait EventDispatcherAwareTrait
8
{
9
10
    /**
11
     * The evetn dispatcher instance.
12
     *
13
     * @var EventDispatcherInterface|null
14
     */
15
    protected $eventDispatcher;
16
17
    /**
18
     * Set the Emitter.
19
     *
20
     * @param EventDispatcherInterface|null $eventDispatcher
21
     *
22
     * @return $this
23
     */
24 7
    public function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null)
25
    {
26 7
        $this->eventDispatcher = $eventDispatcher;
27
28 7
        return $this;
29
    }
30
31
    /**
32
     * Get the Emitter.
33
     *
34
     * @return EmitterInterface
35
     */
36 33
    public function getEventDispatcher()
37
    {
38 33
        if ($this->eventDispatcher instanceof EventDispatcherInterface === false) {
39 33
            $this->eventDispatcher = new DummyEventDispatcher();
40
        }
41
42 33
        return $this->eventDispatcher;
43
    }
44
45
}
46