EventDispatcherHelper::dispatch()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
rs 10
ccs 1
cts 1
cp 1
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\EventDispatcher;
13
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15
use Symfony\Contracts\EventDispatcher\Event;
16
17
/**
18
 * Event dispatcher helper.
19
 *
20
 * @author webeweb <https://github.com/webeweb>
21
 * @package WBW\Bundle\CoreBundle\EventDispatcher
22
 */
23
class EventDispatcherHelper {
24
25
    /**
26
     * Dispatch an event.
27
     *
28
     * @param EventDispatcherInterface|null $eventDispatcher The event dispatcher.
29
     * @param Event $event The event.
30
     * @param string|null $eventName The event name.
31
     * @return Event Returns the event.
32
     */
33
    public static function dispatch(?EventDispatcherInterface $eventDispatcher, Event $event, string $eventName = null): Event {
34 50
        return null === $eventDispatcher ? $event : $eventDispatcher->dispatch($event, $eventName);
35
    }
36
}
37