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.
Completed
Push — master ( 8ed6f1...ecc169 )
by Rodrigue
03:16
created

organiseArguments()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 6.0087

Importance

Changes 4
Bugs 2 Features 1
Metric Value
c 4
b 2
f 1
dl 0
loc 27
ccs 15
cts 16
cp 0.9375
rs 8.439
cc 6
eloc 16
nc 4
nop 2
crap 6.0087
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;
13
14
use Behat\Testwork\Argument\ArgumentOrganiser;
15
use Doctrine\Common\Annotations\Reader;
16
use Gorghoa\ScenarioStateBehatExtension\Annotation\ScenarioStateArgument;
17
use Gorghoa\ScenarioStateBehatExtension\Context\Initializer\ScenarioStateInitializer;
18
use ReflectionFunctionAbstract;
19
20
/**
21
 * @author Rodrigue Villetard <[email protected]>
22
 * @author Vincent Chalamon <[email protected]>
23
 */
24
final class ScenarioStateArgumentOrganiser implements ArgumentOrganiser
25
{
26
    private $baseOrganiser;
27
    private $store;
28
    private $reader;
29
30 1
    public function __construct(ArgumentOrganiser $organiser, ScenarioStateInitializer $store, Reader $reader)
31
    {
32 1
        $this->baseOrganiser = $organiser;
33 1
        $this->store = $store;
34 1
        $this->reader = $reader;
35 1
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function organiseArguments(ReflectionFunctionAbstract $function, array $match)
41
    {
42 1
        $i = array_slice(array_keys($match), -1, 1)[0];
43 1
        $paramsKeys = array_map(function($element) {
44 1
            return $element->name;
45 1
        }, $function->getParameters());
46
47 1
        $store = $this->store->getStore();
48
49 1
        if (!($function instanceof \ReflectionMethod)) {
50
            return $this->baseOrganiser->organiseArguments($function, $match);
51
        }
52
53
        /** @var ScenarioStateArgument[] $annotations */
54 1
        $annotations = $this->reader->getMethodAnnotations($function);
55 1
        foreach ($annotations as $annotation) {
56 1
            if ($annotation instanceof ScenarioStateArgument &&
57 1
                in_array($annotation->getArgument(), $paramsKeys) &&
58 1
                $store->hasStateFragment($annotation->getName())
59
            ) {
60 1
                $match[$annotation->getArgument()] = $store->getStateFragment($annotation->getName());
61 1
                $match[strval(++$i)] = $store->getStateFragment($annotation->getName());
62
            }
63
        }
64
65 1
        return $this->baseOrganiser->organiseArguments($function, $match);
66
    }
67
}
68