ScenarioContainerResetter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ContextServiceExtension package.
7
 *
8
 * (c) Kamil Kokot <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace FriendsOfBehat\ContextServiceExtension\Listener;
15
16
use Behat\Behat\EventDispatcher\Event\ExampleTested;
17
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
18
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
19
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
20
21
/**
22
 * @internal
23
 */
24
final class ScenarioContainerResetter implements EventSubscriberInterface
25
{
26
    /**
27
     * @var ResettableContainerInterface
28
     */
29
    private $scenarioContainer;
30
31
    /**
32
     * @param ResettableContainerInterface $scenarioContainer
33
     */
34
    public function __construct(ResettableContainerInterface $scenarioContainer)
35
    {
36
        $this->scenarioContainer = $scenarioContainer;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public static function getSubscribedEvents(): array
43
    {
44
        return [
45
            ScenarioTested::AFTER => ['reset', -15],
46
            ExampleTested::AFTER => ['reset', -15],
47
        ];
48
    }
49
50
    public function reset(): void
51
    {
52
        $this->scenarioContainer->reset();
53
    }
54
}
55