Passed
Pull Request — master (#1184)
by
unknown
32:37
created

EventDispatcherAwareTrait::dispatchEvent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\OAuth2\Server\Events;
4
5
use Psr\EventDispatcher\EventDispatcherInterface;
6
7
trait EventDispatcherAwareTrait
8
{
9
    /** @var EventDispatcherInterface|null */
10
    protected $eventDispatcher;
11
12
    public function useEventDispatcher(?EventDispatcherInterface $eventDispatcher): void
13
    {
14
        $this->eventDispatcher = $eventDispatcher;
15
    }
16
17
    protected function dispatchEvent(object $event): object
18
    {
19
        if ($this->eventDispatcher !== null) {
20
            return $this->eventDispatcher->dispatch($event);
21
        }
22
23
        return $event;
24
    }
25
}
26