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.

ComponentConfiguration   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 158
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 58
dl 0
loc 158
ccs 0
cts 37
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPersistedQuerySlugBase() 0 14 1
A getSettingsValueLabel() 0 15 1
A getCustomEndpointSlugBase() 0 14 1
A getEmptyLabel() 0 14 1
A groupFieldsUnderTypeForPrint() 0 16 1
A getEditingAccessScheme() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI;
6
7
use GraphQLAPI\GraphQLAPI\Security\UserAuthorization;
8
use PoP\ComponentModel\ComponentConfiguration\EnvironmentValueHelpers;
9
use PoP\ComponentModel\ComponentConfiguration\ComponentConfigurationTrait;
10
11
class ComponentConfiguration
12
{
13
    use ComponentConfigurationTrait;
14
15
    // private static string $getModuleURLBase;
16
    private static bool $groupFieldsUnderTypeForPrint = false;
17
    private static string $getEmptyLabel = '';
18
    private static string $getSettingsValueLabel = '';
19
    private static ?string $getCustomEndpointSlugBase = null;
20
    private static ?string $getPersistedQuerySlugBase = null;
21
    private static ?string $getEditingAccessScheme = null;
22
23
    // /**
24
    //  * URL base for the module, pointing to graphql-api.com
25
    //  *
26
    //  * @return string
27
    //  */
28
    // public static function getModuleURLBase(): string
29
    // {
30
    //     // Define properties
31
    //     $envVariable = Environment::MODULE_URL_BASE;
32
    //     $selfProperty = &self::$getModuleURLBase;
33
    //     $defaultValue = 'https://graphql-api.com/modules/';
34
35
    //     // Initialize property from the environment/hook
36
    //     self::maybeInitializeConfigurationValue(
37
    //         $envVariable,
38
    //         $selfProperty,
39
    //         $defaultValue
40
    //     );
41
    //     return $selfProperty;
42
    // }
43
44
    /**
45
     * Group the fields under the type when printing it for the user
46
     *
47
     * @return boolean
48
     */
49
    public static function groupFieldsUnderTypeForPrint(): bool
50
    {
51
        // Define properties
52
        $envVariable = Environment::GROUP_FIELDS_UNDER_TYPE_FOR_PRINT;
53
        $selfProperty = &self::$groupFieldsUnderTypeForPrint;
54
        $defaultValue = true;
55
        $callback = [EnvironmentValueHelpers::class, 'toBool'];
56
57
        // Initialize property from the environment/hook
58
        self::maybeInitializeConfigurationValue(
59
            $envVariable,
60
            $selfProperty,
61
            $defaultValue,
62
            $callback
63
        );
64
        return $selfProperty;
65
    }
66
67
    /**
68
     * The label to show when the value is empty
69
     */
70
    public static function getEmptyLabel(): string
71
    {
72
        // Define properties
73
        $envVariable = Environment::EMPTY_LABEL;
74
        $selfProperty = &self::$getEmptyLabel;
75
        $defaultValue = \__('---', 'graphql-api');
76
77
        // Initialize property from the environment/hook
78
        self::maybeInitializeConfigurationValue(
79
            $envVariable,
80
            $selfProperty,
81
            $defaultValue
82
        );
83
        return $selfProperty;
84
    }
85
86
    /**
87
     * The label to show when the value comes from the settings
88
     */
89
    public static function getSettingsValueLabel(): string
90
    {
91
        // Define properties
92
        $envVariable = Environment::SETTINGS_VALUE_LABEL;
93
        $selfProperty = &self::$getSettingsValueLabel;
94
        // $defaultValue = \__('As defined in the General Settings', 'graphql-api');
95
        $defaultValue = \__('Default', 'graphql-api');
96
97
        // Initialize property from the environment/hook
98
        self::maybeInitializeConfigurationValue(
99
            $envVariable,
100
            $selfProperty,
101
            $defaultValue
102
        );
103
        return $selfProperty;
104
    }
105
106
    /**
107
     * The slug to use as base when accessing the custom endpoint
108
     *
109
     * @return string
110
     */
111
    public static function getCustomEndpointSlugBase(): string
112
    {
113
        // Define properties
114
        $envVariable = Environment::ENDPOINT_SLUG_BASE;
115
        $selfProperty = &self::$getCustomEndpointSlugBase;
116
        $defaultValue = 'graphql';
117
118
        // Initialize property from the environment/hook
119
        self::maybeInitializeConfigurationValue(
120
            $envVariable,
121
            $selfProperty,
122
            $defaultValue
123
        );
124
        return $selfProperty;
125
    }
126
127
    /**
128
     * The slug to use as base when accessing the persisted query
129
     *
130
     * @return string
131
     */
132
    public static function getPersistedQuerySlugBase(): string
133
    {
134
        // Define properties
135
        $envVariable = Environment::PERSISTED_QUERY_SLUG_BASE;
136
        $selfProperty = &self::$getPersistedQuerySlugBase;
137
        $defaultValue = 'graphql-query';
138
139
        // Initialize property from the environment/hook
140
        self::maybeInitializeConfigurationValue(
141
            $envVariable,
142
            $selfProperty,
143
            $defaultValue
144
        );
145
        return $selfProperty;
146
    }
147
148
    /**
149
     * If `"admin"`, only the admin can compose a GraphQL query and endpoint
150
     * If `"post"`, the workflow from creating posts is employed (i.e. Author role can create
151
     * but not publish the query, Editor role can publish it, etc)
152
     *
153
     * @return string
154
     */
155
    public static function getEditingAccessScheme(): string
156
    {
157
        // Define properties
158
        $envVariable = Environment::EDITING_ACCESS_SCHEME;
159
        $selfProperty = &self::$getEditingAccessScheme;
160
        $defaultValue = UserAuthorization::ACCESS_SCHEME_ADMIN_ONLY;
161
162
        // Initialize property from the environment/hook
163
        self::maybeInitializeConfigurationValue(
164
            $envVariable,
165
            $selfProperty,
166
            $defaultValue
167
        );
168
        return $selfProperty;
169
    }
170
}
171