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 (#40)
by Jérémiah
05:07
created

ConnectionDefinition   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
D toMappingDefinition() 0 61 9
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\Relay\Connection;
13
14
use Overblog\GraphQLBundle\Definition\Builder\MappingInterface;
15
16
class ConnectionDefinition implements MappingInterface
17
{
18 3
    public function toMappingDefinition(array $config)
19
    {
20 3
        $name = $config['name'];
21 3
        $namePrefix = preg_replace('/(.*)?Connection$/', '$1', $name);
22
23
        //Edge
24 3
        $edgeName = $namePrefix.'Edge';
25 3
        $edgeFields = empty($config['edgeFields']) || !is_array($config['edgeFields']) ? [] : $config['edgeFields'];
26 3
        $nodeType = empty($config['nodeType']) || !is_string($config['nodeType']) ? null : $config['nodeType'];
27 3
        $resolveNode = empty($config['resolveNode']) ? null : $config['resolveNode'];
28 3
        $resolveCursor = empty($config['resolveCursor']) ? null : $config['resolveNode'];
29
30
        //connection
31 3
        $connectionName = $namePrefix.'Connection';
32 3
        $connectionFields = empty($config['connectionFields']) || !is_array($config['connectionFields']) ? [] : $config['connectionFields'];
33
34
        return [
35
            $edgeName => [
36 3
                'type' => 'object',
37
                'config' => [
38 3
                    'name' => $edgeName,
39 3
                    'description' => 'An edge in a connection.',
40 3
                    'fields' => array_merge(
41 3
                        $edgeFields,
42
                        [
43
                            'node' => [
44 3
                                'type' => $nodeType,
45 3
                                'resolve' => $resolveNode,
46 3
                                'description' => 'The item at the end of the edge.',
47 3
                            ],
48
                            'cursor' => [
49 3
                                'type' => 'String!',
50 3
                                'resolve' => $resolveCursor,
51 3
                                'description' => 'A cursor for use in pagination.',
52 3
                            ],
53
                        ]
54 3
                    ),
55 3
                ],
56 3
            ],
57
            $connectionName => [
58 3
                'type' => 'object',
59
                'config' => [
60 3
                    'name' => $connectionName,
61 3
                    'description' => 'A connection to a list of items.',
62 3
                    'fields' => array_merge(
63 3
                        $connectionFields,
64
                        [
65
                            'pageInfo' => [
66 3
                                'type' => 'PageInfo!',
67 3
                                'description' => 'Information to aid in pagination.',
68 3
                            ],
69
                            'edges' => [
70 3
                                'type' => "[$edgeName]",
71 3
                                'description' => 'Information to aid in pagination.',
72 3
                            ],
73
                        ]
74 3
                    ),
75 3
                ],
76 3
            ],
77 3
        ];
78
    }
79
}
80