EventSubscriber   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 64.29%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 34
ccs 9
cts 14
cp 0.6429
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 14 2
A output() 0 6 3
1
<?php
2
/**
3
 * @author Sergii Bondarenko, <[email protected]>
4
 */
5
namespace Behat\DebugExtension;
6
7
// Event subscriber.
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
// Feature events.
10
use Behat\Behat\EventDispatcher\Event\FeatureTested;
11
use Behat\Behat\EventDispatcher\Event\AfterFeatureTested;
12
// Scenario events.
13
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
14
use Behat\Behat\EventDispatcher\Event\BeforeScenarioTested;
15
// Step events.
16
use Behat\Behat\EventDispatcher\Event\StepTested;
17
use Behat\Behat\EventDispatcher\Event\AfterStepTested;
18
19
/**
20
 * Class EventSubscriber.
21
 *
22
 * @package Behat\DebugExtension
23
 */
24
class EventSubscriber implements EventSubscriberInterface
25
{
26
    use Debugger;
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 4
    public static function getSubscribedEvents()
32
    {
33 4
        $events = [];
34
35
        foreach ([
36 4
            StepTested::AFTER,
37 4
            FeatureTested::AFTER,
38 4
            ScenarioTested::BEFORE,
39 4
        ] as $event) {
40 4
            $events[$event] = ['output', 100];
41 4
        }
42
43 4
        return $events;
44
    }
45
46
    /**
47
     * Print debug messages.
48
     *
49
     * @param AfterFeatureTested|BeforeScenarioTested|AfterStepTested $event
50
     */
51
    public function output($event)
52
    {
53
        if (method_exists($event, 'getFeature') && $event->getFeature()->hasTag('debug')) {
54
            self::printMessages();
55
        }
56
    }
57
}
58