Completed
Pull Request — master (#50)
by De Cramer
03:04
created

SymfonyEventAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A dispatch() 0 7 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
    /**
26
     * StorageProvider constructor.
27
     *
28
     * @param $connection
29
     */
30 40
    public function __construct(
31
        EventDispatcherInterface $eventDispatcher
32
    ) {
33 40
        $this->symfonyEventDispatcher = $eventDispatcher;
34 40
    }
35
36
37
    /**
38
     * Dispatch event as it needs to be.
39
     *
40
     * @param string $eventName Name of the event.
41
     * @param array $params Parameters
42
     */
43 24
    public function dispatch($eventName, $params)
44
    {
45
46 24
        $event = new DedicatedEvent();
47 24
        $event->setParameters($params);
48 24
        $this->symfonyEventDispatcher->dispatch("maniaplanet.game." . $eventName, $event);
49
    }
50
}