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   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
c 1
b 0
f 0
lcom 2
cbo 1
dl 0
loc 70
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfigKeys() 0 4 1
A getSectionKey() 0 9 2
A getConfigKey() 0 3 1
A getVariant() 0 11 3
A filterConfigTags() 0 6 1
A setVariantTags() 0 4 1
A getConfigTag() 0 10 3
A filterVariantTags() 0 6 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