Passed
Pull Request — 11.0.x (#107)
by Tom
02:36
created

EventDispatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiSkeletons\Doctrine\ORM\GraphQL\Event;
6
7
use League\Event\Emitter as EventDispatcherClass;
8
9
/**
10
 * This class is a wrapper for the League\Event\Emitter class.
11
 * Because the version of League\Event was changed from 3.0 to 2.2,
12
 * this class was created to keep the code consistent and move easily
13
 * move back to 3.0 when the time comes.
14
 */
15
class EventDispatcher
16
{
17
    public function __construct(
18
        protected EventDispatcherClass $eventDispatcher,
19
    ) {
20
    }
21
22
    public function dispatch(string $event, mixed $payload = null): void
23
    {
24
        $this->eventDispatcher->emit($event, $payload);
25
    }
26
27
    public function subscribeTo(string $event, callable $listener): void
28
    {
29
        $this->eventDispatcher->addListener($event, $listener);
30
    }
31
}
32