Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#731)
by Vincent
16:14 queued 13:36
created

ObjectTypeDefinition::treatFieldsDefaultAccess()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.9666
cc 4
nc 1
nop 1
crap 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Config;
6
7
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
8
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
9
use function array_key_exists;
10
11
class ObjectTypeDefinition extends TypeWithOutputFieldsDefinition
12
{
13 47
    public function getDefinition(): ArrayNodeDefinition
14
    {
15 47
        $builder = new TreeBuilder('_object_config', 'array');
16
17
        /** @var ArrayNodeDefinition $node */
18 47
        $node = $builder->getRootNode();
19
20
        /** @phpstan-ignore-next-line */
21
        $node
22 47
            ->children()
23 47
                ->append($this->validationSection(self::VALIDATION_LEVEL_CLASS))
24 47
                ->append($this->nameSection())
25 47
                ->append($this->outputFieldsSection())
26 47
                ->append($this->fieldsBuilderSection())
27 47
                ->append($this->descriptionSection())
28 47
                ->arrayNode('interfaces')
29 47
                    ->prototype('scalar')->info('One of internal or custom interface types.')->end()
30 47
                ->end()
0 ignored issues
show
Bug introduced by
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
                ->/** @scrutinizer ignore-call */ end()
Loading history...
31 47
                ->variableNode('isTypeOf')->end()
32 47
                ->variableNode('resolveField')->end()
33 47
                ->variableNode('fieldsDefaultAccess')
34 47
                    ->info('Default access control to fields (expression language can be use here)')
35 47
                ->end()
36 47
                ->arrayNode('fieldsDefaultAccessConfig')
37 47
                    ->addDefaultsIfNotSet()
38 47
                    ->children()
39 47
                        ->booleanNode('nullOnDenied')->defaultFalse()->end()
40 47
                    ->end()
41 47
                ->end()
42 47
                ->variableNode('fieldsDefaultPublic')
43 47
                    ->info('Default public control to fields (expression language can be use here)')
44 47
                ->end()
45 47
            ->end();
46
47 47
        $this->treatFieldsDefaultAccess($node);
48 47
        $this->treatFieldsDefaultAccessConfig($node);
49 47
        $this->treatFieldsDefaultPublic($node);
50
51 47
        return $node;
52
    }
53
54
    /**
55
     * set empty fields.access with fieldsDefaultAccess values if is set?
56
     */
57 47
    private function treatFieldsDefaultAccess(ArrayNodeDefinition $node): void
58
    {
59 47
        $node->validate()
60 47
        ->ifTrue(fn ($v) => isset($v['fieldsDefaultAccess']))
61 47
            ->then(function ($v) {
62 1
                foreach ($v['fields'] as &$field) {
63 1
                    if (array_key_exists('access', $field) && null !== $field['access']) {
64 1
                        continue;
65
                    }
66 1
                    $field['access'] = $v['fieldsDefaultAccess'];
67
                }
68
69 1
                return $v;
70 47
            })
71 47
        ->end();
72 47
    }
73
74
    /**
75
     * set empty fields.accessConfig with fieldsDefaultAccessConfig values if is set?
76
     */
77 47
    private function treatFieldsDefaultAccessConfig(ArrayNodeDefinition $node): void
78
    {
79 47
        $node->validate()
80 47
            ->ifTrue(fn ($v) => isset($v['fieldsDefaultAccessConfig']))
81 47
            ->then(function ($v) {
82 37
                foreach ($v['fields'] as &$field) {
83 37
                    if (isset($field['accessConfig'])) {
84 37
                        continue;
85
                    }
86
87
                    $field['accessConfig'] = $v['fieldsDefaultAccessConfig'];
88
                }
89
90 37
                return $v;
91 47
            })
92 47
        ->end();
93 47
    }
94
95
    /**
96
     * set empty fields.public with fieldsDefaultPublic values if is set?
97
     */
98 47
    private function treatFieldsDefaultPublic(ArrayNodeDefinition $node): void
99
    {
100 47
        $node->validate()
101 47
            ->ifTrue(fn ($v) => isset($v['fieldsDefaultPublic']))
102 47
            ->then(function ($v) {
103 1
                foreach ($v['fields'] as &$field) {
104 1
                    if (array_key_exists('public', $field) && null !== $field['public']) {
105 1
                        continue;
106
                    }
107 1
                    $field['public'] = $v['fieldsDefaultPublic'];
108
                }
109
110 1
                return $v;
111 47
            })
112 47
        ->end();
113 47
    }
114
}
115