Completed
Push — dev ( 8eacd8...04be10 )
by De Cramer
02:44
created

SymfonyEventAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A dispatch() 0 6 1
1
<?php
2
3
namespace eXpansion\Framework\Core\Services;
4
5
use eXpansion\Framework\Core\Model\Event\DedicatedEvent;
6
use eXpansion\Framework\Core\Services\Application\DispatcherInterface;
7
use eXpansion\Framework\Core\Services\Application\EventProcessorInterface;
8
use eXpansion\Framework\Core\Storage\GameDataStorage;
9
use Maniaplanet\DedicatedServer\Connection;
10
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
11
12
/**
13
 * Class StorageProvider
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 Smile
17
 * @package eXpansion\Framework\Core\Services
18
 */
19
class SymfonyEventAdapter implements EventProcessorInterface
20
{
21
    /** @var EventDispatcherInterface */
22
    protected $symfonyEventDispatcher;
23
24
    /**
25
     * SymfonyEventAdapter constructor.
26
     *
27
     * @param EventDispatcherInterface $eventDispatcher
28
     */
29 46
    public function __construct(
30
        EventDispatcherInterface $eventDispatcher
31
    ) {
32 46
        $this->symfonyEventDispatcher = $eventDispatcher;
33 46
    }
34
35
36
    /**
37
     * Dispatch event as it needs to be.
38
     *
39
     * @param string $eventName Name of the event.
40
     * @param array $params Parameters
41
     */
42 24
    public function dispatch($eventName, $params)
43
    {
44 24
        $event = new DedicatedEvent();
45 24
        $event->setParameters($params);
46 24
        $this->symfonyEventDispatcher->dispatch("maniaplanet.game." . $eventName, $event);
47
    }
48
}