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 ( 8846c9...67b391 )
by 12345
39s
created

PlaceholderArgumentTransformer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace espend\Behat\PlaceholderExtension\Transformer;
5
6
use Behat\Behat\Definition\Call\DefinitionCall;
7
use Behat\Behat\Transformation\Transformer\ArgumentTransformer;
8
use espend\Behat\PlaceholderExtension\Context\PlaceholderContext;
9
use espend\Behat\PlaceholderExtension\PlaceholderBagInterface;
10
use espend\Behat\PlaceholderExtension\Utils\PlaceholderUtil;
11
12
/**
13
 * @author Daniel Espendiller <[email protected]>
14
 */
15
class PlaceholderArgumentTransformer implements ArgumentTransformer
16
{
17
    /**
18
     * @var PlaceholderBagInterface
19
     */
20
    private $placeholderBag;
21
22
    /**
23
     * @param PlaceholderBagInterface $placeholderBag
24
     */
25 8
    public function __construct(PlaceholderBagInterface $placeholderBag)
26
    {
27 8
        $this->placeholderBag = $placeholderBag;
28 8
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 4
    public function supportsDefinitionAndArgument(DefinitionCall $definitionCall, $argumentIndex, $argumentValue)
34
    {
35
        // '%FOO%', '%foo%'
36
        return
37 4
            is_string($argumentValue) &&
38 4
            PlaceholderUtil::isValidPlaceholder($argumentValue) &&
39 1
            ($placeholders = $this->placeholderBag->all()) &&
40 4
            isset($placeholders[$argumentValue])
41
        ;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 4
    public function transformArgument(DefinitionCall $definitionCall, $argumentIndex, $argumentValue)
48
    {
49 4
        $placeholder = $this->placeholderBag->all();
50 4
        if (isset($placeholder[$argumentValue])) {
51 4
            return $placeholder[$argumentValue];
52
        }
53
54 4
        return $argumentValue;
55
    }
56
}
57