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 (#24)
by Vincent
02:48
created

ScenarioStateInitializer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 47
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 6 1
A initializeContext() 0 8 2
A clearStore() 0 4 1
A getStore() 0 4 1
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 Symfony\Component\EventDispatcher\EventSubscriberInterface;
21
22
/**
23
 * @author Rodrigue Villetard <[email protected]>
24
 */
25
class ScenarioStateInitializer implements ContextInitializer, EventSubscriberInterface
26
{
27
    /**
28
     * @var ScenarioStateInterface
29
     */
30
    private $store;
31
32 2
    public function __construct()
33
    {
34 2
        $this->clearStore();
35 2
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public static function getSubscribedEvents()
41
    {
42
        return [
43 1
            ScenarioTested::AFTER => ['clearStore'],
44
        ];
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function initializeContext(Context $context)
51
    {
52 1
        if (!$context instanceof ScenarioStateAwareContext) {
53
            return;
54
        }
55
56 1
        $context->setScenarioState($this->store);
57 1
    }
58
59 2
    public function clearStore()
60
    {
61 2
        $this->store = new ScenarioState();
62 2
    }
63
64
    /**
65
     * @return ScenarioStateInterface
66
     */
67 2
    public function getStore()
68
    {
69 2
        return $this->store;
70
    }
71
}
72