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 ( f7c842...4e8bcc )
by Leonardo
13:59
created

getSettingsDefaultValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
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\ModuleSettings\Properties;
9
use GraphQLAPI\GraphQLAPI\ModuleResolvers\ModuleResolverTrait;
10
11
class OperationalFunctionalityModuleResolver 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
    public const REMOVE_IF_NULL_DIRECTIVE = Plugin::NAMESPACE . '\remove-if-null-directive';
18
    public const PROACTIVE_FEEDBACK = Plugin::NAMESPACE . '\proactive-feedback';
19
20
    /**
21
     * Setting options
22
     */
23
    public const OPTION_USE_NAMESPACING = 'use-namespacing';
24
25
    public static function getModulesToResolve(): array
26
    {
27
        return [
28
            self::SCHEMA_NAMESPACING,
29
            self::MULTIPLE_QUERY_EXECUTION,
30
            self::REMOVE_IF_NULL_DIRECTIVE,
31
            self::PROACTIVE_FEEDBACK,
32
        ];
33
    }
34
35
    /**
36
     * Enable to customize a specific UI for the module
37
     */
38
    public function getModuleSubtype(string $module): ?string
39
    {
40
        return 'pioneering';
41
    }
42
43
    public function getDependedModuleLists(string $module): array
44
    {
45
        switch ($module) {
46
            case self::SCHEMA_NAMESPACING:
47
                return [
48
                    [
49
                        EndpointFunctionalityModuleResolver::SCHEMA_CONFIGURATION,
50
                    ],
51
                ];
52
            case self::MULTIPLE_QUERY_EXECUTION:
53
                return [
54
                    [
55
                        EndpointFunctionalityModuleResolver::PERSISTED_QUERIES,
56
                        EndpointFunctionalityModuleResolver::SINGLE_ENDPOINT,
57
                        EndpointFunctionalityModuleResolver::CUSTOM_ENDPOINTS,
58
                    ],
59
                ];
60
            case self::REMOVE_IF_NULL_DIRECTIVE:
61
            case self::PROACTIVE_FEEDBACK:
62
                return [];
63
        }
64
        return parent::getDependedModuleLists($module);
65
    }
66
67
    public function getName(string $module): string
68
    {
69
        $names = [
70
            self::SCHEMA_NAMESPACING => \__('Schema Namespacing', 'graphql-api'),
71
            self::MULTIPLE_QUERY_EXECUTION => \__('Multiple Query Execution', 'graphql-api'),
72
            self::REMOVE_IF_NULL_DIRECTIVE => \__('Remove if Null', 'graphql-api'),
73
            self::PROACTIVE_FEEDBACK => \__('Proactive Feedback', 'graphql-api'),
74
        ];
75
        return $names[$module] ?? $module;
76
    }
77
78
    public function getDescription(string $module): string
79
    {
80
        switch ($module) {
81
            case self::SCHEMA_NAMESPACING:
82
                return \__('Automatically namespace types and interfaces with a vendor/project name, to avoid naming collisions', 'graphql-api');
83
            case self::MULTIPLE_QUERY_EXECUTION:
84
                return \__('Execute multiple GraphQL queries in a single operation', 'graphql-api');
85
            case self::REMOVE_IF_NULL_DIRECTIVE:
86
                return \__('Addition of <code>@removeIfNull</code> directive, to remove an output from the response if it is <code>null</code>', 'graphql-api');
87
            case self::PROACTIVE_FEEDBACK:
88
                return \__('Usage of the top-level entry <code>extensions</code> to send deprecations, warnings, logs, notices and traces in the response to the query', 'graphql-api');
89
        }
90
        return parent::getDescription($module);
91
    }
92
93
    public function isEnabledByDefault(string $module): bool
94
    {
95
        switch ($module) {
96
            case self::SCHEMA_NAMESPACING:
97
            case self::MULTIPLE_QUERY_EXECUTION:
98
            case self::REMOVE_IF_NULL_DIRECTIVE:
99
                return false;
100
        }
101
        return parent::isEnabledByDefault($module);
102
    }
103
104
    /**
105
     * Default value for an option set by the module
106
     *
107
     * @param string $module
108
     * @param string $option
109
     * @return mixed Anything the setting might be: an array|string|bool|int|null
110
     */
111
    public function getSettingsDefaultValue(string $module, string $option)
112
    {
113
        $defaultValues = [
114
            self::SCHEMA_NAMESPACING => [
115
                self::OPTION_USE_NAMESPACING => false,
116
            ],
117
        ];
118
        return $defaultValues[$module][$option];
119
    }
120
121
    /**
122
     * Array with the inputs to show as settings for the module
123
     *
124
     * @param string $module
125
     * @return array
126
     */
127
    public function getSettings(string $module): array
128
    {
129
        $moduleSettings = parent::getSettings($module);
130
        // Do the if one by one, so that the SELECT do not get evaluated unless needed
131
        if ($module == self::SCHEMA_NAMESPACING) {
132
            $option = self::OPTION_USE_NAMESPACING;
133
            $moduleSettings[] = [
134
                Properties::INPUT => $option,
135
                Properties::NAME => $this->getSettingOptionName(
136
                    $module,
137
                    $option
138
                ),
139
                Properties::TITLE => \__('Use namespacing?', 'graphql-api'),
140
                Properties::DESCRIPTION => \__('Automatically namespace types and interfaces in the schema', 'graphql-api'),
141
                Properties::TYPE => Properties::TYPE_BOOL,
142
            ];
143
        }
144
        return $moduleSettings;
145
    }
146
}
147