TestChooserListener::selectFeature()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Bex\Behat\ChooseTestsExtension\Listener;
4
5
use Bex\Behat\ChooseTestsExtension\Chooser\FeatureChooser;
6
use Bex\Behat\ChooseTestsExtension\Chooser\ScenarioChooser;
7
use Bex\Behat\ChooseTestsExtension\Chooser\SuiteChooser;
8
use Bex\Behat\ChooseTestsExtension\Event\AfterAvailableSuitesRegistered;
9
use Bex\Behat\ChooseTestsExtension\Event\AvailableSuitesRegistered;
10
use Bex\Behat\ChooseTestsExtension\Event\BeforeAvailableSuitesRegistered;
11
use Bex\Behat\ChooseTestsExtension\ServiceContainer\Config;
12
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
13
14
class TestChooserListener implements EventSubscriberInterface
15
{
16
    /**
17
     * @var Config
18
     */
19
    private $config;
20
    
21
    /**
22
     * @var SuiteChooser
23
     */
24
    private $suiteChooser;
25
    
26
    /**
27
     * @var FeatureChooser
28
     */
29
    private $featureChooser;
30
    
31
    /**
32
     * @var ScenarioChooser
33
     */
34
    private $scenarioChooser;
35
    
36
    /**
37
     * @param Config          $config
38
     * @param SuiteChooser    $suiteChooser
39
     * @param FeatureChooser  $featureChooser
40
     * @param ScenarioChooser $scenarioChooser
41
     */
42
    public function __construct(
43
        Config $config,
44
        SuiteChooser $suiteChooser,
45
        FeatureChooser $featureChooser,
46
        ScenarioChooser $scenarioChooser
47
    ) {
48
        $this->config = $config;
49
        $this->suiteChooser = $suiteChooser;
50
        $this->featureChooser = $featureChooser;
51
        $this->scenarioChooser = $scenarioChooser;
52
    }
53
    
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public static function getSubscribedEvents()
58
    {
59
        return [
60
            AvailableSuitesRegistered::BEFORE => [
61
                ['selectSuite']
62
            ],
63
            AvailableSuitesRegistered::AFTER => [
64
                ['selectFeature'],
65
                ['selectScenario']
66
            ],
67
        ];
68
    }
69
70
    public function selectSuite(BeforeAvailableSuitesRegistered $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
    {
72
        if ($this->config->isSuiteSelectorEnabled()) {
73
            $this->suiteChooser->execute();
74
        }
75
    }
76
77
    public function selectFeature(AfterAvailableSuitesRegistered $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
    {
79
        if ($this->config->isFeatureSelectorEnabled()) {
80
            $this->featureChooser->execute();
81
        }
82
    }
83
84
    public function selectScenario(AfterAvailableSuitesRegistered $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
    {
86
        if ($this->config->isScenarioSelectorEnabled()) {
87
            $this->scenarioChooser->execute();
88
        }
89
    }
90
}
91