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

AccessControlFunctionalityModuleResolver::getSettings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 51
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
eloc 37
c 4
b 0
f 0
nc 2
nop 1
dl 0
loc 51
ccs 0
cts 49
cp 0
crap 6
rs 9.328

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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