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

Passed
Push — master ( 4b9dd3...0fc96b )
by Jérémiah
19:14
created

MutationFieldDefinition   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 32
Duplicated Lines 31.25 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 10
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toMappingDefinition() 0 18 6
A cleanMutateAndGetPayload() 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
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Relay\Mutation;
6
7
use Overblog\GraphQLBundle\Definition\Builder\MappingInterface;
8
9
final class MutationFieldDefinition implements MappingInterface
10
{
11 4
    public function toMappingDefinition(array $config): array
12
    {
13 4
        if (!\array_key_exists('mutateAndGetPayload', $config)) {
14 1
            throw new \InvalidArgumentException('Mutation "mutateAndGetPayload" config is required.');
15
        }
16
17 3
        $mutateAndGetPayload = $this->cleanMutateAndGetPayload($config['mutateAndGetPayload']);
18 3
        $payloadType = isset($config['payloadType']) && \is_string($config['payloadType']) ? $config['payloadType'] : null;
19 3
        $inputType = isset($config['inputType']) && \is_string($config['inputType']) ? $config['inputType'].'!' : null;
20
21
        return [
22 3
            'type' => $payloadType,
23
            'args' => [
24 3
                'input' => ['type' => $inputType],
25
            ],
26 3
            'resolve' => "@=resolver('relay_mutation_field', [args, context, info, mutateAndGetPayloadCallback($mutateAndGetPayload)])",
27
        ];
28
    }
29
30 3 View Code Duplication
    private function cleanMutateAndGetPayload($mutateAndGetPayload)
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...
31
    {
32 3
        if (\is_string($mutateAndGetPayload) && 0 === \strpos($mutateAndGetPayload, '@=')) {
33 3
            $cleanMutateAndGetPayload = \substr($mutateAndGetPayload, 2);
34
        } else {
35 2
            $cleanMutateAndGetPayload = \json_encode($mutateAndGetPayload);
36
        }
37
38 3
        return $cleanMutateAndGetPayload;
39
    }
40
}
41