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

EventDispatcherAwareTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 39
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setEventDispatcher() 0 6 1
A getEventDispatcher() 0 8 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