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

PluralIdentifyingRootFieldDefinition   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 43
Duplicated Lines 44.19 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 11
c 1
b 1
f 0
lcom 0
cbo 0
dl 19
loc 43
ccs 21
cts 21
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
C toMappingDefinition() 9 29 8
A cleanResolveSingleInput() 10 10 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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