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:53
created

RuntimeCallHandler::handleCall()   C

Complexity

Conditions 7
Paths 12

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
c 0
b 0
f 0
rs 6.7272
cc 7
eloc 15
nc 12
nop 1
1
<?php
2
3
/*
4
 * This file is part of the StepArgumentInjectorBehatExtension 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\StepArgumentInjectorBehatExtension\Call\Handler;
13
14
use Behat\Behat\Transformation\Call\TransformationCall;
15
use Behat\Testwork\Call\Call;
16
use Behat\Testwork\Call\Handler\CallHandler;
17
use Behat\Testwork\Environment\Call\EnvironmentCall;
18
use Behat\Testwork\Hook\Call\HookCall;
19
use Gorghoa\StepArgumentInjectorBehatExtension\Resolver\ArgumentsResolver;
20
21
/**
22
 * @author Vincent Chalamon <[email protected]>
23
 */
24
final class RuntimeCallHandler implements CallHandler
25
{
26
    /**
27
     * @var CallHandler
28
     */
29
    private $decorated;
30
31
    /**
32
     * @var ArgumentsResolver
33
     */
34
    private $argumentsResolver;
35
36
    /**
37
     * @param CallHandler       $decorated
38
     * @param ArgumentsResolver $argumentsResolver
39
     */
40
    public function __construct(CallHandler $decorated, ArgumentsResolver $argumentsResolver)
41
    {
42
        $this->decorated = $decorated;
43
        $this->argumentsResolver = $argumentsResolver;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function supportsCall(Call $call)
50
    {
51
        return $this->decorated->supportsCall($call);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function handleCall(Call $call)
58
    {
59
        /** @var \ReflectionMethod $function */
60
        $function = $call->getCallee()->getReflection();
61
        $arguments = $call->getArguments();
62
63
        if ($call instanceof HookCall) {
64
            $scope = $call->getScope();
65
66
            // Manage `scope` argument
67
            foreach ($function->getParameters() as $parameter) {
68
                if (null !== $parameter->getClass() && get_class($scope) === $parameter->getClass()->getName()) {
0 ignored issues
show
Bug introduced by
Consider using $parameter->getClass()->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
69
                    $arguments[$parameter->getName()] = $scope;
0 ignored issues
show
Bug introduced by
Consider using $parameter->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
70
                    break;
71
                }
72
            }
73
        }
74
75
        $arguments = $this->argumentsResolver->resolve($function, $arguments);
76
77
        if ($call instanceof TransformationCall) {
78
            $call = new TransformationCall($call->getEnvironment(), $call->getDefinition(), $call->getCallee(), $arguments);
79
        } elseif ($call instanceof HookCall) {
80
            $call = new EnvironmentCall($call->getScope()->getEnvironment(), $call->getCallee(), $arguments);
81
        }
82
83
        return $this->decorated->handleCall($call);
84
    }
85
}
86