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

cleanMutateAndGetPayload()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 10
loc 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.9332
cc 3
nc 2
nop 1
crap 3
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