Passed
Pull Request — master (#1428)
by Andrew
09:33
created

EmitterAwarePolyfill::setEmitter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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