Passed
Pull Request — develop (#5)
by ANTHONIUS
05:33
created

EventDispatcher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 27
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A dispatch() 0 6 2
1
<?php
2
3
4
namespace Doyo\Behat\Coverage\Bridge\Symfony;
5
6
use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher;
7
8
/**
9
 * Maintain backward compatibility with symfony version
10
 *
11
 * @package Doyo\Behat\Coverage\Bridge\Symfony
12
 */
13
class EventDispatcher extends BaseEventDispatcher
14
{
15
    private $version = '4.2';
16
17 1
    public function __construct()
18
    {
19 1
        parent::__construct();
20
21 1
        $r = new \ReflectionClass('\Symfony\Component\EventDispatcher\EventDispatcher');
22 1
        $params = $r->getMethod('dispatch')->getParameters();
23 1
        if('event' === $params[0]->getName()){
24 1
            $this->version = '4.3';
25
        }
26
    }
27
28
    /**
29
     * @param Event     $event
30
     * @param string    $eventName
31
     *
32
     * @return Event
33
     */
34 1
    public function dispatch($event, $eventName = null)
35
    {
36 1
        if('4.2' === $this->version){
37
            return parent::dispatch($eventName, $event);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::dispatch($eventName, $event) also could return the type string which is incompatible with the documented return type Doyo\Behat\Coverage\Bridge\Symfony\Event.
Loading history...
38
        }
39 1
        return parent::dispatch($event, $eventName);
40
    }
41
}
42