EventSubscriber::output()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
cc 3
eloc 3
nc 2
nop 1
crap 12
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