GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#31)
by Rodrigue
01:55
created

ScenarioStateInitializer::hasStepArgumentFor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
ccs 0
cts 2
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the ScenarioStateBehatExtension project.
5
 *
6
 * (c) Rodrigue Villetard <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gorghoa\ScenarioStateBehatExtension\Context\Initializer;
13
14
use Behat\Behat\Context\Context;
15
use Behat\Behat\Context\Initializer\ContextInitializer;
16
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
17
use Gorghoa\ScenarioStateBehatExtension\Context\ScenarioStateAwareContext;
18
use Gorghoa\ScenarioStateBehatExtension\ScenarioState;
19
use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface;
20
use Gorghoa\StepArgumentInjectorBehatExtension\Argument\StepArgumentHolder;
21
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
22
23
/**
24
 * @author Rodrigue Villetard <[email protected]>
25
 */
26
class ScenarioStateInitializer implements ContextInitializer, EventSubscriberInterface, StepArgumentHolder
27
{
28
    /**
29
     * @var ScenarioStateInterface
30
     */
31
    private $store;
32
33 2
    public function __construct()
34
    {
35 2
        $this->clearStore();
36 2
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public static function getSubscribedEvents()
42
    {
43
        return [
44 1
            ScenarioTested::AFTER => ['clearStore'],
45
        ];
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    public function initializeContext(Context $context)
52
    {
53 1
        if (!$context instanceof ScenarioStateAwareContext) {
54
            return;
55
        }
56
57 1
        $context->setScenarioState($this->store);
58 1
    }
59
60 2
    public function clearStore()
61
    {
62 2
        $this->store = new ScenarioState();
63 2
    }
64
65
    /**
66
     * @return ScenarioStateInterface
67
     */
68 2
    public function getStore()
69
    {
70 2
        return $this->store;
71
    }
72
73
    public function hasStepArgumentFor($key)
74
    {
75
        return $this->store->hasStateFragment($key);
76
    }
77
78
    public function getStepArgumentFor($key)
79
    {
80
        return $this->store->getStateFragment($key);
81
    }
82
}
83