Completed
Pull Request — master (#1028)
by
unknown
04:36
created

EventDispatcherAwareTrait::setEventDispatcher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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