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 (#682)
by
unknown
06:13
created

TypeWithOutputFieldsDefinition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 70
c 2
b 0
f 0
dl 0
loc 92
ccs 68
cts 68
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B outputFieldsSection() 0 75 3
A fieldsBuilderSection() 0 13 1
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\NodeDefinition;
9
10
abstract class TypeWithOutputFieldsDefinition extends TypeDefinition
11
{
12 47
    protected function outputFieldsSection(): NodeDefinition
13
    {
14 47
        $node = self::createNode('fields');
15
        $node
16 47
            ->isRequired()
17 47
            ->requiresAtLeastOneElement();
0 ignored issues
show
Bug introduced by
The method requiresAtLeastOneElement() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

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

17
            ->/** @scrutinizer ignore-call */ requiresAtLeastOneElement();
Loading history...
18
19
        /* @var ArrayNodeDefinition $prototype */
20 47
        $prototype = $node->useAttributeAsKey('name', false)->prototype('array');
0 ignored issues
show
Bug introduced by
The method useAttributeAsKey() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

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

20
        $prototype = $node->/** @scrutinizer ignore-call */ useAttributeAsKey('name', false)->prototype('array');
Loading history...
Bug introduced by
The method prototype() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

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

20
        $prototype = $node->useAttributeAsKey('name', false)->/** @scrutinizer ignore-call */ prototype('array');
Loading history...
21
22
        $prototype
23 47
            ->beforeNormalization()
24
                // Allow field type short syntax (Field: Type => Field: {type: Type})
25 47
                ->ifTrue(fn ($options) => \is_string($options))
26 47
                ->then(fn ($options) => ['type' => $options])
27 47
            ->end()
28 47
            ->validate()
29
                // Remove empty entries
30
                ->always(function ($value) {
31 37
                    if (empty($value['validationGroups'])) {
32 37
                        unset($value['validationGroups']);
33
                    }
34
35 37
                    if (empty($value['args'])) {
36 37
                        unset($value['args']);
37
                    }
38
39 37
                    return $value;
40 47
                })
41 47
            ->end()
42 47
            ->children()
43 47
                ->append($this->typeSection())
44 47
                ->append($this->validationSection(self::VALIDATION_LEVEL_CLASS))
45 47
                ->arrayNode('validationGroups')
46 47
                    ->beforeNormalization()
47 47
                        ->castToArray()
48 47
                    ->end()
49 47
                    ->prototype('scalar')
50 47
                        ->info('List of validation groups')
51 47
                    ->end()
52 47
                ->end()
53 47
                ->arrayNode('args')
54 47
                    ->info('Array of possible type arguments. Each entry is expected to be an array with following keys: name (string), type')
55 47
                    ->useAttributeAsKey('name', false)
56 47
                    ->prototype('array')
57
                        // Allow arg type short syntax (Arg: Type => Arg: {type: Type})
58 47
                        ->beforeNormalization()
59 47
                            ->ifTrue(fn ($options) => \is_string($options))
60 47
                            ->then(fn ($options) => ['type' => $options])
61 47
                        ->end()
62 47
                        ->children()
63 47
                            ->append($this->typeSection(true))
64 47
                            ->append($this->descriptionSection())
65 47
                            ->append($this->defaultValueSection())
66 47
                            ->append($this->validationSection(self::VALIDATION_LEVEL_PROPERTY))
67 47
                        ->end()
68 47
                    ->end()
69 47
                ->end()
70 47
                ->variableNode('resolve')
71 47
                    ->info('Value resolver (expression language can be used here)')
72 47
                ->end()
73 47
                ->append($this->descriptionSection())
74 47
                ->append($this->deprecationReasonSection())
75 47
                ->variableNode('access')
76 47
                    ->info('Access control to field (expression language can be used here)')
77 47
                ->end()
78 47
                ->variableNode('public')
79 47
                    ->info('Visibility control to field (expression language can be used here)')
80 47
                ->end()
81 47
                ->variableNode('complexity')
82 47
                    ->info('Custom complexity calculator.')
83 47
                ->end()
84 47
            ->end();
85
86 47
        return $node;
87
    }
88
89 47
    protected function fieldsBuilderSection()
90
    {
91 47
        $node = self::createNode('builders');
92
93 47
        $prototype = $node->prototype('array');
94
95
        $prototype
96 47
            ->children()
97 47
                ->variableNode('builder')->isRequired()->end()
98 47
                ->variableNode('builderConfig')->end()
99 47
            ->end();
100
101 47
        return $node;
102
    }
103
}
104