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 ( f06828...aea366 )
by Leonardo
08:36
created

getDependedModuleLists()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 11
nc 6
nop 1
dl 0
loc 20
ccs 0
cts 20
cp 0
crap 42
rs 9.2222
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI\ModuleResolvers;
6
7
use GraphQLAPI\GraphQLAPI\Plugin;
8
use GraphQLAPI\GraphQLAPI\ModuleResolvers\ModuleResolverTrait;
9
use GraphQLAPI\GraphQLAPI\ModuleResolvers\SchemaConfigurationFunctionalityModuleResolver;
10
11
class AccessControlFunctionalityModuleResolver extends AbstractFunctionalityModuleResolver
12
{
13
    use ModuleResolverTrait {
14
        ModuleResolverTrait::hasDocumentation as upstreamHasDocumentation;
15
    }
16
17
    public const ACCESS_CONTROL = Plugin::NAMESPACE . '\access-control';
18
    public const ACCESS_CONTROL_RULE_DISABLE_ACCESS = Plugin::NAMESPACE . '\access-control-rule-disable-access';
19
    public const ACCESS_CONTROL_RULE_USER_STATE = Plugin::NAMESPACE . '\access-control-rule-user-state';
20
    public const ACCESS_CONTROL_RULE_USER_ROLES = Plugin::NAMESPACE . '\access-control-rule-user-roles';
21
    public const ACCESS_CONTROL_RULE_USER_CAPABILITIES = Plugin::NAMESPACE . '\access-control-rule-user-capabilities';
22
23
    public static function getModulesToResolve(): array
24
    {
25
        return [
26
            self::ACCESS_CONTROL,
27
            self::ACCESS_CONTROL_RULE_DISABLE_ACCESS,
28
            self::ACCESS_CONTROL_RULE_USER_STATE,
29
            self::ACCESS_CONTROL_RULE_USER_ROLES,
30
            self::ACCESS_CONTROL_RULE_USER_CAPABILITIES,
31
        ];
32
    }
33
34
    /**
35
     * Enable to customize a specific UI for the module
36
     */
37
    public function getModuleSubtype(string $module): ?string
38
    {
39
        return 'accesscontrol';
40
    }
41
42
    public function getDependedModuleLists(string $module): array
43
    {
44
        switch ($module) {
45
            case self::ACCESS_CONTROL:
46
                return [
47
                    [
48
                        SchemaConfigurationFunctionalityModuleResolver::SCHEMA_CONFIGURATION,
49
                    ],
50
                ];
51
            case self::ACCESS_CONTROL_RULE_DISABLE_ACCESS:
52
            case self::ACCESS_CONTROL_RULE_USER_STATE:
53
            case self::ACCESS_CONTROL_RULE_USER_ROLES:
54
            case self::ACCESS_CONTROL_RULE_USER_CAPABILITIES:
55
                return [
56
                    [
57
                        self::ACCESS_CONTROL,
58
                    ],
59
                ];
60
        }
61
        return parent::getDependedModuleLists($module);
62
    }
63
64
    public function getName(string $module): string
65
    {
66
        $names = [
67
            self::ACCESS_CONTROL => \__('Access Control', 'graphql-api'),
68
            self::ACCESS_CONTROL_RULE_DISABLE_ACCESS => \__('Access Control Rule: Disable Access', 'graphql-api'),
69
            self::ACCESS_CONTROL_RULE_USER_STATE => \__('Access Control Rule: User State', 'graphql-api'),
70
            self::ACCESS_CONTROL_RULE_USER_ROLES => \__('Access Control Rule: User Roles', 'graphql-api'),
71
            self::ACCESS_CONTROL_RULE_USER_CAPABILITIES => \__('Access Control Rule: User Capabilities', 'graphql-api'),
72
        ];
73
        return $names[$module] ?? $module;
74
    }
75
76
    public function getDescription(string $module): string
77
    {
78
        switch ($module) {
79
            case self::ACCESS_CONTROL:
80
                return \__('Set-up rules to define who can access the different fields and directives from a schema', 'graphql-api');
81
            case self::ACCESS_CONTROL_RULE_DISABLE_ACCESS:
82
                return \__('Remove access to the fields and directives', 'graphql-api');
83
            case self::ACCESS_CONTROL_RULE_USER_STATE:
84
                return \__('Allow or reject access to the fields and directives based on the user being logged-in or not', 'graphql-api');
85
            case self::ACCESS_CONTROL_RULE_USER_ROLES:
86
                return \__('Allow or reject access to the fields and directives based on the user having a certain role', 'graphql-api');
87
            case self::ACCESS_CONTROL_RULE_USER_CAPABILITIES:
88
                return \__('Allow or reject access to the fields and directives based on the user having a certain capability', 'graphql-api');
89
        }
90
        return parent::getDescription($module);
91
    }
92
93
    /**
94
     * Does the module have HTML Documentation?
95
     */
96
    public function hasDocumentation(string $module): bool
97
    {
98
        switch ($module) {
99
            case self::ACCESS_CONTROL_RULE_DISABLE_ACCESS:
100
            case self::ACCESS_CONTROL_RULE_USER_STATE:
101
            case self::ACCESS_CONTROL_RULE_USER_ROLES:
102
            case self::ACCESS_CONTROL_RULE_USER_CAPABILITIES:
103
                return false;
104
        }
105
        return $this->upstreamHasDocumentation($module);
106
    }
107
}
108