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 ( 42691d...4b52c8 )
by Leonardo
03:01
created

getModulesToResolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI\ModuleResolvers;
6
7
use GraphQLAPI\GraphQLAPI\Plugin;
8
use GraphQLAPI\GraphQLAPI\ModuleSettings\Properties;
9
use GraphQLAPI\GraphQLAPI\ModuleResolvers\ModuleResolverTrait;
10
11
class PioneeringFunctionalityModuleResolver extends AbstractFunctionalityModuleResolver
12
{
13
    use ModuleResolverTrait;
14
15
    public const SCHEMA_NAMESPACING = Plugin::NAMESPACE . '\schema-namespacing';
16
    public const MULTIPLE_QUERY_EXECUTION = Plugin::NAMESPACE . '\multiple-query-execution';
17
18
    /**
19
     * Setting options
20
     */
21
    public const OPTION_USE_NAMESPACING = 'use-namespacing';
22
23
    public static function getModulesToResolve(): array
24
    {
25
        return [
26
            self::SCHEMA_NAMESPACING,
27
            self::MULTIPLE_QUERY_EXECUTION,
28
        ];
29
    }
30
31
    public function getDependedModuleLists(string $module): array
32
    {
33
        switch ($module) {
34
            case self::SCHEMA_NAMESPACING:
35
                return [
36
                    [
37
                        FunctionalityModuleResolver::SCHEMA_CONFIGURATION,
38
                    ],
39
                ];
40
            case self::MULTIPLE_QUERY_EXECUTION:
41
                return [
42
                    [
43
                        FunctionalityModuleResolver::PERSISTED_QUERIES,
44
                        FunctionalityModuleResolver::SINGLE_ENDPOINT,
45
                        FunctionalityModuleResolver::CUSTOM_ENDPOINTS,
46
                    ],
47
                ];
48
        }
49
        return parent::getDependedModuleLists($module);
50
    }
51
52
    public function getName(string $module): string
53
    {
54
        $names = [
55
            self::SCHEMA_NAMESPACING => \__('Schema Namespacing', 'graphql-api'),
56
            self::MULTIPLE_QUERY_EXECUTION => \__('Multiple Query Execution', 'graphql-api'),
57
        ];
58
        return $names[$module] ?? $module;
59
    }
60
61
    public function getDescription(string $module): string
62
    {
63
        switch ($module) {
64
            case self::SCHEMA_NAMESPACING:
65
                return \__('Automatically namespace types and interfaces with a vendor/project name, to avoid naming collisions', 'graphql-api');
66
            case self::MULTIPLE_QUERY_EXECUTION:
67
                return \__('Execute multiple GraphQL queries in a single operation', 'graphql-api');
68
        }
69
        return parent::getDescription($module);
70
    }
71
72
    public function isEnabledByDefault(string $module): bool
73
    {
74
        switch ($module) {
75
            case self::SCHEMA_NAMESPACING:
76
            case self::MULTIPLE_QUERY_EXECUTION:
77
                return false;
78
        }
79
        return parent::isEnabledByDefault($module);
80
    }
81
82
    /**
83
     * Default value for an option set by the module
84
     *
85
     * @param string $module
86
     * @param string $option
87
     * @return mixed Anything the setting might be: an array|string|bool|int|null
88
     */
89
    public function getSettingsDefaultValue(string $module, string $option)
90
    {
91
        $defaultValues = [
92
            self::SCHEMA_NAMESPACING => [
93
                self::OPTION_USE_NAMESPACING => false,
94
            ],
95
        ];
96
        return $defaultValues[$module][$option];
97
    }
98
99
    /**
100
     * Array with the inputs to show as settings for the module
101
     *
102
     * @param string $module
103
     * @return array
104
     */
105
    public function getSettings(string $module): array
106
    {
107
        $moduleSettings = parent::getSettings($module);
108
        // Do the if one by one, so that the SELECT do not get evaluated unless needed
109
        if ($module == self::SCHEMA_NAMESPACING) {
110
            $option = self::OPTION_USE_NAMESPACING;
111
            $moduleSettings[] = [
112
                Properties::INPUT => $option,
113
                Properties::NAME => $this->getSettingOptionName(
114
                    $module,
115
                    $option
116
                ),
117
                Properties::TITLE => \__('Use namespacing?', 'graphql-api'),
118
                Properties::DESCRIPTION => \__('Automatically namespace types and interfaces in the schema', 'graphql-api'),
119
                Properties::TYPE => Properties::TYPE_BOOL,
120
            ];
121
        }
122
        return $moduleSettings;
123
    }
124
}
125