Listener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 3
b 0
f 0
dl 0
loc 23
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getSubscribedEvents() 0 5 1
A clear() 0 3 1
1
<?php declare(strict_types=1);
2
namespace Behapi\HttpHistory;
3
4
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
5
6
use Behat\Behat\EventDispatcher\Event\ExampleTested;
7
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
8
9
/**
10
 * Starts a new "section" in the HttpHistory object when a scenario-like is
11
 * starting, and clean everything once it's done
12
 *
13
 * @author Baptiste Clavié <[email protected]>
14
 */
15
final class Listener implements EventSubscriberInterface
16
{
17
    /** @var History */
18
    private $history;
19
20
    public function __construct(History $history)
21
    {
22
        $this->history = $history;
23
    }
24
25
    /** {@inheritDoc} */
26
    public static function getSubscribedEvents()
27
    {
28
        return [
29
            ExampleTested::AFTER => ['clear', -99],
30
            ScenarioTested::AFTER => ['clear', -99],
31
        ];
32
    }
33
34
    /** Resets the current history of the current client */
35
    public function clear(): void
36
    {
37
        $this->history->reset();
38
    }
39
}
40