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

Passed
Pull Request — master (#237)
by Jérémiah
08:39
created

outputFieldsSelection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 52
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 52
ccs 19
cts 19
cp 1
rs 9.4929
c 0
b 0
f 0
cc 1
eloc 43
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Overblog\GraphQLBundle\Config;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
8
abstract class TypeWithOutputFieldsDefinition extends TypeDefinition
9
{
10
    /**
11
     * @param string $name
12
     *
13
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
14
     */
15 30
    protected function outputFieldsSelection($name)
16
    {
17 30
        $builder = new TreeBuilder();
18 30
        $node = $builder->root($name);
19
        $node
20 30
            ->isRequired()
21 30
            ->requiresAtLeastOneElement();
22
23
        /* @var ArrayNodeDefinition $prototype */
24 30
        $prototype = $node->useAttributeAsKey('name', false)->prototype('array');
25
26
        $prototype
27 30
            ->children()
28 30
                ->append($this->typeSelection())
29 30
                ->arrayNode('args')
30 30
                    ->info('Array of possible type arguments. Each entry is expected to be an array with following keys: name (string), type')
31 30
                    ->useAttributeAsKey('name', false)
32 30
                    ->prototype('array')
33
                        // Allow arg type short syntax (Arg: Type => Arg: {type: Type})
34 30
                        ->beforeNormalization()
35 30
                            ->ifTrue(function ($options) {
36 17
                                return is_string($options);
37 30
                            })
38 30
                            ->then(function ($options) {
39 1
                                return ['type' => $options];
40 30
                            })
41
                        ->end()
42
                        ->children()
43
                            ->append($this->typeSelection(true))
44
                            ->append($this->descriptionSection())
45
                            ->append($this->defaultValueSection())
46
                        ->end()
47
                    ->end()
48
                ->end()
49
                ->variableNode('resolve')
50
                    ->info('Value resolver (expression language can be use here)')
51
                ->end()
52
                ->append($this->descriptionSection())
53
                ->append($this->deprecationReasonSelection())
54
                ->variableNode('access')
55
                    ->info('Access control to field (expression language can be use here)')
56
                ->end()
57
                ->variableNode('public')
58
                    ->info('Visibility control to field (expression language can be use here)')
59
                ->end()
60
                ->variableNode('complexity')
61
                    ->info('Custom complexity calculator.')
62
                ->end()
63
            ->end();
64
65
        return $node;
66
    }
67
}
68