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
Push — master ( 7e7a73...d8bfad )
by Rodrigue
04:11
created

ScenarioStateHookableScenarioTester   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 34.48 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 20
loc 58
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setUp() 10 10 2
A test() 0 4 1
A tearDown() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Hook\Tester;
13
14
use Behat\Behat\Hook\Scope\AfterScenarioScope;
15
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
16
use Behat\Behat\Tester\ScenarioTester;
17
use Behat\Gherkin\Node\FeatureNode;
18
use Behat\Gherkin\Node\ScenarioInterface as Scenario;
19
use Behat\Testwork\Environment\Environment;
20
use Behat\Testwork\Hook\Tester\Setup\HookedSetup;
21
use Behat\Testwork\Hook\Tester\Setup\HookedTeardown;
22
use Behat\Testwork\Tester\Result\TestResult;
23
use Gorghoa\ScenarioStateBehatExtension\Hook\Dispatcher\ScenarioStateHookDispatcher;
24
25
/**
26
 * @author Vincent Chalamon <[email protected]>
27
 */
28
final class ScenarioStateHookableScenarioTester implements ScenarioTester
29
{
30
    /**
31
     * @var ScenarioTester
32
     */
33
    private $baseTester;
34
35
    /**
36
     * @var ScenarioStateHookDispatcher
37
     */
38
    private $dispatcher;
39
40
    /**
41
     * @param ScenarioTester      $baseTester
42
     * @param ScenarioStateHookDispatcher $dispatcher
43
     */
44 3
    public function __construct(ScenarioTester $baseTester, ScenarioStateHookDispatcher $dispatcher)
45
    {
46 3
        $this->baseTester = $baseTester;
47 3
        $this->dispatcher = $dispatcher;
48 3
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1 View Code Duplication
    public function setUp(Environment $env, FeatureNode $feature, Scenario $scenario, $skip)
54
    {
55 1
        $setup = $this->baseTester->setUp($env, $feature, $scenario, true);
56
57 1
        if ($skip) {
58 1
            return $setup;
59
        }
60
61
        return new HookedSetup($setup, $this->dispatcher->dispatchScopeHooks(new BeforeScenarioScope($env, $feature, $scenario)));
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67 1
    public function test(Environment $env, FeatureNode $feature, Scenario $scenario, $skip)
68
    {
69 1
        return $this->baseTester->test($env, $feature, $scenario, $skip);
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75 1 View Code Duplication
    public function tearDown(Environment $env, FeatureNode $feature, Scenario $scenario, $skip, TestResult $result)
76
    {
77 1
        $teardown = $this->baseTester->tearDown($env, $feature, $scenario, true, $result);
78
79 1
        if ($skip) {
80 1
            return $teardown;
81
        }
82
83
        return new HookedTeardown($teardown, $this->dispatcher->dispatchScopeHooks(new AfterScenarioScope($env, $feature, $scenario, $result)));
84
    }
85
}
86