ClientAwareInitializer::__construct()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Behat\Client;
12
13
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
14
use Behat\Behat\EventDispatcher\Tester\EventDispatchingScenarioTester;
15
use Behat\Behat\Tester\Result\StepResult;
16
use Behat\Behat\Tester\ScenarioTester;
17
use Behat\Behat\Tester\StepTester;
18
use Behat\Gherkin\Node\FeatureNode;
19
use Behat\Gherkin\Node\ScenarioInterface;
20
use Behat\Gherkin\Node\StepNode;
21
use Behat\Testwork\Environment\Environment;
22
use Behat\Testwork\Tester\Result\TestResult;
23
24
/**
25
 * Inject GraphQLClient instance on very context implementing ClientAwareInterface
26
 */
27
class ClientAwareInitializer implements ScenarioTester
28
{
29
    /**
30
     * @var StepTester
31
     */
32
    private $baseTester;
33
34
    /**
35
     * @var GraphQLClient
36
     */
37
    private $client;
38
39
    public function __construct(EventDispatchingScenarioTester $baseTester, GraphQLClient $client)
40
    {
41
        $this->baseTester = $baseTester;
0 ignored issues
show
Documentation Bug introduced by
It seems like $baseTester of type Behat\Behat\EventDispatc...spatchingScenarioTester is incompatible with the declared type Behat\Behat\Tester\StepTester of property $baseTester.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
        $this->client = $client;
43
    }
44
45
    public function setUp(Environment $env, FeatureNode $feature, ScenarioInterface $step, $skip)
46
    {
47
        return $this->baseTester->setUp($env, $feature, $step, $skip);
0 ignored issues
show
Bug introduced by
$step of type Behat\Gherkin\Node\ScenarioInterface is incompatible with the type Behat\Gherkin\Node\StepNode expected by parameter $step of Behat\Behat\Tester\StepTester::setUp(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
        return $this->baseTester->setUp($env, $feature, /** @scrutinizer ignore-type */ $step, $skip);
Loading history...
48
    }
49
50
    public function test(Environment $env, FeatureNode $feature, ScenarioInterface $step, $skip)
51
    {
52
        /** @var InitializedContextEnvironment $env */
53
        foreach ($env->getContexts() as $context) {
0 ignored issues
show
Bug introduced by
The method getContexts() does not exist on Behat\Testwork\Environment\Environment. It seems like you code against a sub-type of Behat\Testwork\Environment\Environment such as Behat\Behat\Context\Envi...lizedContextEnvironment or Behat\Behat\Context\Envi...lizedContextEnvironment. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        foreach ($env->/** @scrutinizer ignore-call */ getContexts() as $context) {
Loading history...
54
            if ($context instanceof ClientAwareInterface) {
55
                $context->setClient($this->client);
56
            }
57
        }
58
59
        return $this->baseTester->test($env, $feature, $step, $skip);
0 ignored issues
show
Bug introduced by
$step of type Behat\Gherkin\Node\ScenarioInterface is incompatible with the type Behat\Gherkin\Node\StepNode expected by parameter $step of Behat\Behat\Tester\StepTester::test(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
        return $this->baseTester->test($env, $feature, /** @scrutinizer ignore-type */ $step, $skip);
Loading history...
60
    }
61
62
    public function tearDown(Environment $env, FeatureNode $feature, ScenarioInterface $step, $skip, TestResult $result)
63
    {
64
        return $this->baseTester->tearDown($env, $feature, $step, $skip, $result);
0 ignored issues
show
Bug introduced by
$step of type Behat\Gherkin\Node\ScenarioInterface is incompatible with the type Behat\Gherkin\Node\StepNode expected by parameter $step of Behat\Behat\Tester\StepTester::tearDown(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
        return $this->baseTester->tearDown($env, $feature, /** @scrutinizer ignore-type */ $step, $skip, $result);
Loading history...
65
    }
66
}