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 — 0.11 (#427)
by Jérémiah
20:28 queued 17:07
created

TypeDefinition   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 4
dl 0
loc 86
ccs 34
cts 34
cp 1
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
getDefinition() 0 1 ?
A resolveTypeSection() 0 6 1
A defaultValueSection() 0 6 1
A descriptionSection() 0 6 1
A deprecationReasonSelection() 0 8 1
A typeSelection() 0 12 2
A __construct() 0 3 1
A create() 0 4 1
A nameSection() 0 13 1
A createNode() 0 4 1
1
<?php
2
3
namespace Overblog\GraphQLBundle\Config;
4
5
use Overblog\GraphQLBundle\DependencyInjection\Configuration;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
8
abstract class TypeDefinition
9
{
10
    abstract public function getDefinition();
11
12 37
    protected function __construct()
13
    {
14 37
    }
15
16
    /**
17
     * @return static
18
     */
19 37
    public static function create()
20
    {
21 37
        return new static();
22
    }
23
24 37
    protected function resolveTypeSection()
25
    {
26 37
        $node = self::createNode('resolveType', 'variable');
27
28 37
        return $node;
29
    }
30
31 37
    protected function nameSection()
32
    {
33 37
        $node = self::createNode('name', 'scalar');
34 37
        $node->isRequired();
35 37
        $node->validate()
36
            ->ifTrue(function ($name) {
37 32
                return !\preg_match('/^[_a-z][_0-9a-z]*$/i', $name);
38 37
            })
39 37
                ->thenInvalid('Invalid type name "%s". (see https://facebook.github.io/graphql/October2016/#Name)')
40 37
        ->end();
41
42 37
        return $node;
43
    }
44
45 37
    protected function defaultValueSection()
46
    {
47 37
        $node = self::createNode('defaultValue', 'variable');
48
49 37
        return $node;
50
    }
51
52 37
    protected function descriptionSection()
53
    {
54 37
        $node = self::createNode('description', 'scalar');
55
56 37
        return $node;
57
    }
58
59 37
    protected function deprecationReasonSelection()
60
    {
61 37
        $node = self::createNode('deprecationReason', 'scalar');
62
63 37
        $node->info('Text describing why this field is deprecated. When not empty - field will not be returned by introspection queries (unless forced)');
64
65 37
        return $node;
66
    }
67
68 37
    protected function typeSelection($isRequired = false)
69
    {
70 37
        $node = self::createNode('type', 'scalar');
71
72 37
        $node->info('One of internal or custom types.');
73
74 37
        if ($isRequired) {
75 37
            $node->isRequired();
76
        }
77
78 37
        return $node;
79
    }
80
81
    /**
82
     * @internal
83
     *
84
     * @param string $name
85
     * @param string $type
86
     *
87
     * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
88
     */
89 37
    protected static function createNode($name, $type = 'array')
90
    {
91 37
        return Configuration::getRootNodeWithoutDeprecation(new TreeBuilder($name, $type), $name, $type);
0 ignored issues
show
Unused Code introduced by
The call to TreeBuilder::__construct() has too many arguments starting with $name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
92
    }
93
}
94