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 (#277)
by Jérémiah
20:41
created

ObjectTypeDefinition::treatResolveField()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 15
cts 15
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 12
nc 1
nop 1
crap 4
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
class ObjectTypeDefinition extends TypeWithOutputFieldsDefinition
9
{
10 29
    public function getDefinition()
11
    {
12 29
        $builder = new TreeBuilder();
13 29
        $node = $builder->root('_object_config');
14
15
        $node
0 ignored issues
show
Bug introduced by
The method variableNode() does not seem to exist on object<Symfony\Component...odeDefinitionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
16 29
            ->children()
17 29
                ->append($this->nameSection())
18 29
                ->append($this->outputFieldsSelection())
19 29
                ->append($this->descriptionSection())
20 29
                ->arrayNode('interfaces')
21 29
                    ->prototype('scalar')->info('One of internal or custom interface types.')->end()
22 29
                ->end()
23 29
                ->variableNode('isTypeOf')->end()
24 29
                ->variableNode('resolveField')->end()
25 29
                ->variableNode('fieldsDefaultAccess')
26 29
                    ->info('Default access control to fields (expression language can be use here)')
27 29
                ->end()
28 29
                ->variableNode('fieldsDefaultPublic')
29 29
                    ->info('Default public control to fields (expression language can be use here)')
30 29
                ->end()
31 29
            ->end();
32
33 29
        $this->treatFieldsDefaultAccess($node);
34 29
        $this->treatFieldsDefaultPublic($node);
35 29
36
        return $node;
37 29
    }
38
39
    /**
40
     * set empty fields.access with fieldsDefaultAccess values if is set?
41
     *
42
     * @param ArrayNodeDefinition $node
43
     */
44 View Code Duplication
    private function treatFieldsDefaultAccess(ArrayNodeDefinition $node)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45 29
    {
46
        $node->validate()
47 29
            ->ifTrue(function ($v) {
48 29
                return array_key_exists('fieldsDefaultAccess', $v) && null !== $v['fieldsDefaultAccess'];
49 24
            })
50 29
            ->then(function ($v) {
51 29
                foreach ($v['fields'] as &$field) {
52 1
                    if (array_key_exists('access', $field) && null !== $field['access']) {
53 1
                        continue;
54 1
                    }
55
56
                    $field['access'] = $v['fieldsDefaultAccess'];
57 1
                }
58
59
                return $v;
60 1
            })
61 29
        ->end();
62 29
    }
63 29
64
    /**
65
     * set empty fields.public with fieldsDefaultPublic values if is set?
66
     *
67
     * @param ArrayNodeDefinition $node
68
     */
69 View Code Duplication
    private function treatFieldsDefaultPublic(ArrayNodeDefinition $node)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70 29
    {
71
        $node->validate()
72 29
            ->ifTrue(function ($v) {
73 29
                return array_key_exists('fieldsDefaultPublic', $v) && null !== $v['fieldsDefaultPublic'];
74 24
            })
75 29
            ->then(function ($v) {
76 29
                foreach ($v['fields'] as &$field) {
77 1
                    if (array_key_exists('public', $field) && null !== $field['public']) {
78 1
                        continue;
79 1
                    }
80
81
                    $field['public'] = $v['fieldsDefaultPublic'];
82 1
                }
83
84
                return $v;
85 1
            })
86 29
        ->end();
87 29
    }
88
}
89