Passed
Pull Request — master (#1308)
by Frank
30:36
created

EmitterAwarePolyfill::getEventDispatcher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace League\OAuth2\Server\EventEmitting;
5
6
use League\Event\ListenerRegistry;
7
use Psr\EventDispatcher\EventDispatcherInterface;
8
9
trait EmitterAwarePolyfill
10
{
11
    /**
12
     * @var EventEmitter
13
     */
14
    private $emitter;
15
16
    public function getEmitter(): EventEmitter
17
    {
18
        if ( ! $this->emitter) {
19
            $this->emitter = new EventEmitter();
20
        }
21
22
        return $this->emitter;
23
    }
24
25
    /**
26
     * @return $this
27
     */
28
    public function setEmitter(EventEmitter $emitter)
29
    {
30
        $this->emitter = $emitter;
31
32
        return $this;
33
    }
34
35
    public function getEventDispatcher(): EventDispatcherInterface
36
    {
37
        return $this->getEmitter();
38
    }
39
40
    public function getListenerRegistry(): ListenerRegistry
41
    {
42
        return $this->getEmitter();
43
    }
44
}