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 ( 045419...f7c842 )
by Leonardo
02:57
created

getDescription()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 4
nop 1
dl 0
loc 15
ccs 0
cts 15
cp 0
crap 20
rs 9.9
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\ModuleResolvers\ModuleResolverTrait;
9
10
class UserInterfaceFunctionalityModuleResolver extends AbstractFunctionalityModuleResolver
11
{
12
    use ModuleResolverTrait;
13
14
    public const EXCERPT_AS_DESCRIPTION = Plugin::NAMESPACE . '\excerpt-as-description';
15
    public const LOW_LEVEL_PERSISTED_QUERY_EDITING = Plugin::NAMESPACE . '\low-level-persisted-query-editing';
16
    public const WELCOME_GUIDES = Plugin::NAMESPACE . '\welcome-guides';
17
18
    public static function getModulesToResolve(): array
19
    {
20
        return [
21
            self::LOW_LEVEL_PERSISTED_QUERY_EDITING,
22
            self::EXCERPT_AS_DESCRIPTION,
23
            self::WELCOME_GUIDES,
24
        ];
25
    }
26
27
    public function getDependedModuleLists(string $module): array
28
    {
29
        switch ($module) {
30
            case self::LOW_LEVEL_PERSISTED_QUERY_EDITING:
31
                return [
32
                    [
33
                        EndpointFunctionalityModuleResolver::PERSISTED_QUERIES,
34
                    ],
35
                ];
36
            case self::EXCERPT_AS_DESCRIPTION:
37
                return [];
38
            case self::WELCOME_GUIDES:
39
                return [
40
                    [
41
                        EndpointFunctionalityModuleResolver::PERSISTED_QUERIES,
42
                        EndpointFunctionalityModuleResolver::CUSTOM_ENDPOINTS,
43
                    ],
44
                ];
45
        }
46
        return parent::getDependedModuleLists($module);
47
    }
48
49
    public function areRequirementsSatisfied(string $module): bool
50
    {
51
        switch ($module) {
52
            case self::WELCOME_GUIDES:
53
                /**
54
                 * WordPress 5.5 or above, or Gutenberg 8.2 or above
55
                 */
56
                return
57
                    \is_wp_version_compatible('5.5') ||
58
                    (
59
                        defined('GUTENBERG_VERSION') &&
60
                        \version_compare(constant('GUTENBERG_VERSION'), '8.2', '>=')
61
                    );
62
        }
63
        return parent::areRequirementsSatisfied($module);
64
    }
65
66
    public function isHidden(string $module): bool
67
    {
68
        switch ($module) {
69
            case self::WELCOME_GUIDES:
70
                return true;
71
        }
72
        return parent::isHidden($module);
73
    }
74
75
    public function getName(string $module): string
76
    {
77
        $names = [
78
            self::EXCERPT_AS_DESCRIPTION => \__('Excerpt as Description', 'graphql-api'),
79
            self::LOW_LEVEL_PERSISTED_QUERY_EDITING => \__('Low-Level Persisted Query Editing', 'graphql-api'),
80
            self::WELCOME_GUIDES => \__('Welcome Guides', 'graphql-api'),
81
        ];
82
        return $names[$module] ?? $module;
83
    }
84
85
    public function getDescription(string $module): string
86
    {
87
        switch ($module) {
88
            case self::EXCERPT_AS_DESCRIPTION:
89
                return \__('Provide a description of the different entities (Custom Endpoints, Persisted Queries, and others) through their excerpt', 'graphql-api');
90
            case self::LOW_LEVEL_PERSISTED_QUERY_EDITING:
91
                return \__('Have access to directives to be applied to the schema when editing persisted queries', 'graphql-api');
92
            case self::WELCOME_GUIDES:
93
                return sprintf(
94
                    \__('Display welcome guides which demonstrate how to use the plugin\'s different functionalities. <em>It requires WordPress version \'%s\' or above, or Gutenberg version \'%s\' or above</em>', 'graphql-api'),
95
                    '5.5',
96
                    '8.2'
97
                );
98
        }
99
        return parent::getDescription($module);
100
    }
101
102
    public function isEnabledByDefault(string $module): bool
103
    {
104
        switch ($module) {
105
            case self::LOW_LEVEL_PERSISTED_QUERY_EDITING:
106
            case self::WELCOME_GUIDES:
107
                return false;
108
        }
109
        return parent::isEnabledByDefault($module);
110
    }
111
}
112