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 ( 4c3b7e...cb6ff1 )
by Leonardo
03:37
created

AddonFunctionalityModuleResolver   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 50
c 1
b 0
f 0
dl 0
loc 95
ccs 0
cts 78
cp 0
rs 10
wmc 19

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getDependedModuleLists() 0 15 4
A getModulesToResolve() 0 6 1
A isHidden() 0 7 2
A areRequirementsSatisfied() 0 15 4
A getDescription() 0 15 4
A isEnabledByDefault() 0 8 3
A getName() 0 8 1
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 AddonFunctionalityModuleResolver extends AbstractFunctionalityModuleResolver
11
{
12
    use ModuleResolverTrait;
13
14
    public const EXCERPT_AS_DESCRIPTION = Plugin::NAMESPACE . '\excerpt-as-description';
15
    public const LOW_LEVEL_QUERY_EDITING = Plugin::NAMESPACE . '\low-level-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_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_QUERY_EDITING:
31
            case self::EXCERPT_AS_DESCRIPTION:
32
                return [];
33
            case self::WELCOME_GUIDES:
34
                return [
35
                    [
36
                        FunctionalityModuleResolver::PERSISTED_QUERIES,
37
                        FunctionalityModuleResolver::CUSTOM_ENDPOINTS,
38
                    ],
39
                ];
40
        }
41
        return parent::getDependedModuleLists($module);
42
    }
43
44
    public function areRequirementsSatisfied(string $module): bool
45
    {
46
        switch ($module) {
47
            case self::WELCOME_GUIDES:
48
                /**
49
                 * WordPress 5.5 or above, or Gutenberg 8.2 or above
50
                 */
51
                return
52
                    \is_wp_version_compatible('5.5') ||
53
                    (
54
                        defined('GUTENBERG_VERSION') &&
55
                        \version_compare(constant('GUTENBERG_VERSION'), '8.2', '>=')
56
                    );
57
        }
58
        return parent::areRequirementsSatisfied($module);
59
    }
60
61
    public function isHidden(string $module): bool
62
    {
63
        switch ($module) {
64
            case self::WELCOME_GUIDES:
65
                return true;
66
        }
67
        return parent::isHidden($module);
68
    }
69
70
    public function getName(string $module): string
71
    {
72
        $names = [
73
            self::EXCERPT_AS_DESCRIPTION => \__('Excerpt as Description', 'graphql-api'),
74
            self::LOW_LEVEL_QUERY_EDITING => \__('Low-Level Query Editing', 'graphql-api'),
75
            self::WELCOME_GUIDES => \__('Welcome Guides', 'graphql-api'),
76
        ];
77
        return $names[$module] ?? $module;
78
    }
79
80
    public function getDescription(string $module): string
81
    {
82
        switch ($module) {
83
            case self::EXCERPT_AS_DESCRIPTION:
84
                return \__('Provide a description of the different entities (Custom Endpoints, Persisted Queries, and others) through their excerpt', 'graphql-api');
85
            case self::LOW_LEVEL_QUERY_EDITING:
86
                return \__('Have access to schema-configuration low-level directives when editing GraphQL queries in the admin', 'graphql-api');
87
            case self::WELCOME_GUIDES:
88
                return sprintf(
89
                    \__('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'),
90
                    '5.4',
91
                    '6.1'
92
                );
93
        }
94
        return parent::getDescription($module);
95
    }
96
97
    public function isEnabledByDefault(string $module): bool
98
    {
99
        switch ($module) {
100
            case self::LOW_LEVEL_QUERY_EDITING:
101
            case self::WELCOME_GUIDES:
102
                return false;
103
        }
104
        return parent::isEnabledByDefault($module);
105
    }
106
}
107