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   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A supportsDefinitionAndArgument() 0 10 4
A transformArgument() 0 9 2
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