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 ( 573a46...de67c0 )
by Leonardo
03:28
created

AccessControlBlock   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 38
c 3
b 0
f 0
dl 0
loc 90
ccs 0
cts 66
cp 0
rs 10
wmc 12

8 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCommonStyleCSS() 0 3 1
A getBlockCategory() 0 4 1
A getBlockName() 0 3 1
A registerEditorCSS() 0 3 1
A getBlockContent() 0 29 4
A getBlockDataTitle() 0 3 1
A getLocalizedData() 0 6 1
A getBlockContentTitle() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI\Blocks;
6
7
use PoP\AccessControl\Schema\SchemaModes;
8
use PoP\AccessControl\ComponentConfiguration;
9
use GraphQLAPI\GraphQLAPI\Blocks\AbstractControlBlock;
10
use GraphQLAPI\GraphQLAPI\Facades\ModuleRegistryFacade;
11
use GraphQLAPI\GraphQLAPI\Blocks\GraphQLByPoPBlockTrait;
12
use PoP\ComponentModel\Facades\Instances\InstanceManagerFacade;
13
use GraphQLAPI\GraphQLAPI\BlockCategories\AbstractBlockCategory;
14
use GraphQLAPI\GraphQLAPI\BlockCategories\AccessControlBlockCategory;
15
use GraphQLAPI\GraphQLAPI\ModuleResolvers\AccessControlFunctionalityModuleResolver;
16
17
/**
18
 * Access Control block
19
 */
20
class AccessControlBlock extends AbstractControlBlock
21
{
22
    use GraphQLByPoPBlockTrait;
23
24
    public const ATTRIBUTE_NAME_SCHEMA_MODE = 'schemaMode';
25
26
    protected function getBlockName(): string
27
    {
28
        return 'access-control';
29
    }
30
31
    protected function getBlockCategory(): ?AbstractBlockCategory
32
    {
33
        $instanceManager = InstanceManagerFacade::getInstance();
34
        return $instanceManager->getInstance(AccessControlBlockCategory::class);
35
    }
36
37
    protected function registerEditorCSS(): bool
38
    {
39
        return true;
40
    }
41
42
    protected function registerCommonStyleCSS(): bool
43
    {
44
        return true;
45
    }
46
47
    protected function getBlockDataTitle(): string
48
    {
49
        return \__('Define access for:', 'graphql-api');
50
    }
51
    protected function getBlockContentTitle(): string
52
    {
53
        if (ComponentConfiguration::enableIndividualControlForPublicPrivateSchemaMode()) {
54
            return \__('Access Control Rules:', 'graphql-api');
55
        }
56
        return \__('Who can access:', 'graphql-api');
57
    }
58
59
    /**
60
     * Pass localized data to the block
61
     *
62
     * @return array
63
     */
64
    protected function getLocalizedData(): array
65
    {
66
        return array_merge(
67
            parent::getLocalizedData(),
68
            [
69
                'isIndividualControlForSchemaModeEnabled' => ComponentConfiguration::enableIndividualControlForPublicPrivateSchemaMode(),
70
            ]
71
        );
72
    }
73
74
    /**
75
     * Return the nested blocks' content
76
     *
77
     * @param array $attributes
78
     * @param string $content
79
     * @return string
80
     */
81
    protected function getBlockContent(array $attributes, string $content): string
82
    {
83
        $maybeSchemaModeContent = '';
84
        if (ComponentConfiguration::enableIndividualControlForPublicPrivateSchemaMode()) {
85
            $blockContentPlaceholder = <<<EOT
86
                <p><strong>%s</strong> %s</p>
87
                <h4 class="%s">%s</h4>
88
EOT;
89
            $className = $this->getBlockClassName() . '-front';
90
            $schemaModeLabels = [
91
                SchemaModes::PUBLIC_SCHEMA_MODE => \__('Public', 'graphql-api'),
92
                SchemaModes::PRIVATE_SCHEMA_MODE => \__('Private', 'graphql-api'),
93
            ];
94
            $maybeSchemaModeContent = sprintf(
95
                $blockContentPlaceholder,
96
                \__('Public/Private Schema:', 'graphql-api'),
97
                $attributes[self::ATTRIBUTE_NAME_SCHEMA_MODE] ?
98
                    $schemaModeLabels[$attributes[self::ATTRIBUTE_NAME_SCHEMA_MODE]]
99
                    : \__('Default', 'graphql-api'),
100
                $className . '__title',
101
                \__('Who can access:', 'graphql-api')
102
            );
103
        }
104
        if ($content) {
105
            return $maybeSchemaModeContent . $content;
106
        }
107
        return $maybeSchemaModeContent . sprintf(
108
            '<em>%s</em>',
109
            \__('(not set)', 'graphql-api')
110
        );
111
    }
112
}
113