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

ScenarioStateHookableScenarioTester   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 38.71 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 24
loc 62
ccs 14
cts 18
cp 0.7778
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setUp() 12 12 2
A test() 0 4 1
A tearDown() 12 12 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)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55 1
        $setup = $this->baseTester->setUp($env, $feature, $scenario, true);
56
57 1
        if ($skip) {
58 1
            return $setup;
59
        }
60
61
        $hookCallResults = $this->dispatcher->dispatchScopeHooks(new BeforeScenarioScope($env, $feature, $scenario));
62
63
        return new HookedSetup($setup, $hookCallResults);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 1
    public function test(Environment $env, FeatureNode $feature, Scenario $scenario, $skip)
70
    {
71 1
        return $this->baseTester->test($env, $feature, $scenario, $skip);
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 1 View Code Duplication
    public function tearDown(Environment $env, FeatureNode $feature, Scenario $scenario, $skip, TestResult $result)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
    {
79 1
        $teardown = $this->baseTester->tearDown($env, $feature, $scenario, true, $result);
80
81 1
        if ($skip) {
82 1
            return $teardown;
83
        }
84
85
        $hookCallResults = $this->dispatcher->dispatchScopeHooks(new AfterScenarioScope($env, $feature, $scenario, $result));
86
87
        return new HookedTeardown($teardown, $hookCallResults);
88
    }
89
}
90