SymfonyBridge::getOriginal()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of phpab/phpab. (https://github.com/phpab/phpab)
4
 *
5
 * @link https://github.com/phpab/phpab for the canonical source repository
6
 * @copyright Copyright (c) 2015-2016 phpab. (https://github.com/phpab/)
7
 * @license https://raw.githubusercontent.com/phpab/phpab/master/LICENSE.md MIT
8
 */
9
10
namespace PhpAb\Event;
11
12
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13
14
/**
15
 * An event dispatcher that acts as a bridge between phpab and Symfony.
16
 *
17
 * @package PhpAb
18
 */
19
class SymfonyBridge implements DispatcherInterface
20
{
21
    /**
22
     * The event dispatcher used to invoke events.
23
     *
24
     * @var EventDispatcherInterface
25
     */
26
    private $eventDispatcher;
27
28
    /**
29
     * Initializes a new instance of this class.
30
     *
31
     * @param EventDispatcherInterface $eventDispatcher The Symfony EventDispatcher
32
     */
33 4
    public function __construct(EventDispatcherInterface $eventDispatcher)
34
    {
35 4
        $this->eventDispatcher = $eventDispatcher;
36 4
    }
37
38
    /**
39
     * {@inheritDoc}
40
     *
41
     * @param string $event The name of the Event which should be dispatched
42
     * @param array $options The options that should get passed to the callback
43
     */
44 4
    public function dispatch($event, $options)
45
    {
46 4
        $listeners = $this->eventDispatcher->getListeners($event);
47
48 4
        foreach ($listeners as $listener) {
49 3
            call_user_func($listener, $options);
50 4
        }
51 4
    }
52
53
    /**
54
     * Gets the original EventDispatcher
55
     *
56
     * @return EventDispatcherInterface
57
     */
58 3
    public function getOriginal()
59
    {
60 3
        return $this->eventDispatcher;
61
    }
62
}
63