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
13:22
created

toMappingDefinition()   C

Complexity

Conditions 8
Paths 5

Size

Total Lines 29
Code Lines 16

Duplication

Lines 9
Ratio 31.03 %

Code Coverage

Tests 16
CRAP Score 8

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 9
loc 29
ccs 16
cts 16
cp 1
rs 5.3846
cc 8
eloc 16
nc 5
nop 1
crap 8
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\Node;
13
14
use GraphQL\Type\Definition\Config;
15
use Overblog\GraphQLBundle\Definition\Builder\MappingInterface;
16
use Overblog\GraphQLBundle\Definition\Type;
17
18
class PluralIdentifyingRootFieldDefinition implements MappingInterface
19
{
20 15
    public function toMappingDefinition(array $config)
21
    {
22 15 View Code Duplication
        if (!isset($config['argName']) || !is_string($config['argName'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
23 2
            throw new \InvalidArgumentException('A valid pluralIdentifyingRoot "argName" config is required.');
24
        }
25
26 13 View Code Duplication
        if (!isset($config['inputType']) || !is_string($config['inputType'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
27 2
            throw new \InvalidArgumentException('A valid pluralIdentifyingRoot "inputType" config is required.');
28
        }
29
30 11 View Code Duplication
        if (!isset($config['outputType']) || !is_string($config['outputType'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
31 2
            throw new \InvalidArgumentException('A valid pluralIdentifyingRoot "outputType" config is required.');
32
        }
33
34 9
        if (!array_key_exists('resolveSingleInput', $config)) {
35 1
            throw new \InvalidArgumentException('PluralIdentifyingRoot "resolveSingleInput" config is required.');
36
        }
37
38 8
        $argName = $config['argName'];
39
40
        return [
41 8
            'type' => "[${config['outputType']}]",
42
            'args' => [$argName => ['type' => "[${config['inputType']}!]!"]],
43 8
            'resolve' => sprintf(
44 8
                "@=resolver('relay_plural_identifying_field', [args['$argName'], resolveSingleInputCallback(%s)])",
45 8
                $this->cleanResolveSingleInput($config['resolveSingleInput'])
46 8
            ),
47 8
        ];
48
    }
49
50 View Code Duplication
    private function cleanResolveSingleInput($resolveSingleInput)
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...
51
    {
52 8
        if (is_string($resolveSingleInput) &&  0 === strpos($resolveSingleInput, '@=')) {
53 2
            $cleanResolveSingleInput = substr($resolveSingleInput, 2);
54 2
        } else {
55 6
            $cleanResolveSingleInput = json_encode($resolveSingleInput);
56
        }
57
58 8
        return $cleanResolveSingleInput;
59
    }
60
}
61