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 (#23)
by Jérémiah
12:18
created

FieldDefinition   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 62
ccs 25
cts 25
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefinition() 0 9 1
A createMap() 0 12 3
A create() 0 6 1
A __construct() 0 6 2
A getComplexityFn() 0 4 1
A defaultComplexity() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Definition;
13
14
use GraphQL\Type\Definition\Config;
15
use GraphQL\Type\Definition\FieldDefinition as BaseFieldDefinition;
16
17
class FieldDefinition extends BaseFieldDefinition
18
{
19
    /**
20
     * @var callable
21
     */
22
    private $complexityFn;
23
24 38
    public static function getDefinition()
25
    {
26 38
        return array_merge(
27 38
            parent::getDefinition(),
28
            [
29 38
                'complexity' => Config::CALLBACK,
30
            ]
31 38
        );
32
    }
33
34 37
    public static function createMap(array $fields)
35
    {
36 37
        $map = [];
37 37
        foreach ($fields as $name => $field) {
38 37
            if (!isset($field['name'])) {
39 37
                $field['name'] = $name;
40 37
            }
41 37
            $map[$name] = static::create($field);
42 37
        }
43
44 37
        return $map;
45
    }
46
47
    /**
48
     * @param array|Config $field
49
     *
50
     * @return FieldDefinition
51
     */
52 37
    public static function create($field)
53
    {
54 37
        Config::validate($field, static::getDefinition());
0 ignored issues
show
Bug introduced by
It seems like $field defined by parameter $field on line 52 can also be of type object<GraphQL\Type\Definition\Config>; however, GraphQL\Type\Definition\Config::validate() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
55
56 37
        return new static($field);
0 ignored issues
show
Bug introduced by
It seems like $field defined by parameter $field on line 52 can also be of type object<GraphQL\Type\Definition\Config>; however, Overblog\GraphQLBundle\D...finition::__construct() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
57
    }
58
59 37
    protected function __construct(array $config)
60
    {
61 37
        parent::__construct($config);
62
63 37
        $this->complexityFn = isset($config['complexity']) ? $config['complexity'] : [$this, 'defaultComplexity'];
64 37
    }
65
66
    /**
67
     * @return callable|\Closure
68
     */
69 10
    public function getComplexityFn()
70
    {
71 10
        return $this->complexityFn;
72
    }
73
74 12
    public static function defaultComplexity($childrenComplexity)
75
    {
76 12
        return $childrenComplexity + 1;
77
    }
78
}
79