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.

PlaceholderUtils::getConfigTag()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace Ciandt\Behat\PlaceholdersExtension\Utils;
4
5
use Ciandt\Behat\PlaceholdersExtension\Exception\RedundantConfigTagException;
6
7
/**
8
 * Filters an array of tags, excluding or including only the variant tags
9
 *
10
 * @author bwowk
11
 */
12
class PlaceholderUtils
13
{
14
    private static $variantTags;
15
    
16
    private static $configKeys;
17
18
    public static function setVariantTags($variantTags)
19
    {
20
        self::$variantTags = $variantTags;
21
    }
22
    
23
    public static function setConfigKeys($configKeys)
24
    {
25
        self::$configKeys = $configKeys;
26
    }
27
    
28
    public static  function getSectionKey($tag){
29
        $tagParts = explode(':', $tag);
30
        if (count($tagParts) == 2){
31
            return $tagParts[1];
32
        } else {
33
            return 'default';
34
        }
35
        
36
    }
37
    
38
    public static function getConfigTag($tags){
39
        $configTags = self::filterConfigTags($tags,false);
40
        if (empty($configTags)) {
41
            return false;
42
        }
43
        if (count($configTags) > 1) {
44
            throw new RedundantConfigTagException($configTags);
45
        }
46
        return $configTags[0];
47
    }
48
49
50
    public static function getConfigKey($tag){
51
        return explode(':', $tag)[0];
52
    }
53
    
54
    
55
    public static function filterVariantTags($tags, $exclude)
56
    {   
57
        return array_filter($tags, function ($tag) use ($exclude) {
58
            return (in_array($tag, self::$variantTags) xor $exclude);
59
        });
60
    }
61
    
62
    public static function getVariant($tags){
63
        $variantTags = self::filterVariantTags($tags, false);
64
        if (count($variantTags) > 1) {
65
            throw new \RuntimeException("Scenario should only have one variant tag."
66
                    . " Multiple found: " . implode(', ', $variantTags));
67
        }
68
        if (empty($variantTags)){
69
            return 'default';
70
        }
71
        return end($variantTags);
72
    }
73
74
75
    public static function filterConfigTags($tags, $exclude)
76
    {
77
        return array_filter($tags, function ($tag) use ($exclude){
78
            return (in_array(self::getConfigKey($tag), self::$configKeys) xor $exclude);
79
        });
80
    }
81
}
82