AsyncEventExecutor::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Workana\AsyncJobs\Executor;
3
4
use Workana\AsyncJobs\AsyncEvent;
5
use Interop\Container\ContainerInterface;
6
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
7
8
/**
9
 * Executes an async event
10
 *
11
 * @author Carlos Frutos <[email protected]>
12
 */
13
class AsyncEventExecutor
14
{
15
    /**
16
     * @var EventDispatcherInterface
17
     */
18
    protected $eventDispatcher;
19
20
    /**
21
     * @var EventDispatcherInterface $eventDispatcher
22
     */
23
    public function __construct(EventDispatcherInterface $eventDispatcher)
24
    {
25
        $this->eventDispatcher = $eventDispatcher;
26
    }
27
28
    /**
29
     * Invokes the executor
30
     *
31
     * @var AsyncEvent $asyncEvent
32
     *
33
     * @return void
34
     */
35
    public function __invoke(AsyncEvent $asyncEvent)
36
    {
37
        $this->eventDispatcher->dispatch($asyncEvent->getEventName(), $asyncEvent->getEvent());
38
    }
39
}