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
Push — master ( 024700...341ac6 )
by Jérémiah
04:30
created

MutationFieldDefinition::toMappingDefinition()   B

Complexity

Conditions 6
Paths 17

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 8.8571
cc 6
eloc 11
nc 17
nop 1
crap 6
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\Mutation;
13
14
use GraphQL\Type\Definition\Config;
15
use Overblog\GraphQLBundle\Definition\Builder\MappingInterface;
16
use Overblog\GraphQLBundle\Definition\Type;
17
18
class MutationFieldDefinition implements MappingInterface
19
{
20 3
    public function toMappingDefinition(array $config)
21
    {
22 3
        if (!array_key_exists('mutateAndGetPayload', $config)) {
23 1
            throw new \InvalidArgumentException('Mutation "mutateAndGetPayload" config is required.');
24
        }
25
26 2
        $mutateAndGetPayload = $this->cleanMutateAndGetPayload($config['mutateAndGetPayload']);
27 2
        $payloadType = isset($config['payloadType']) && is_string($config['payloadType']) ? $config['payloadType'] : null;
28 2
        $inputType = isset($config['inputType']) && is_string($config['inputType']) ? $config['inputType'].'!' : null;
29
30
        return [
31 2
            'type' => $payloadType,
32
            'args' => [
33 2
                'input' => ['type' => $inputType],
34 2
            ],
35 2
            'resolve' => "@=resolver('relay_mutation_field', [args, mutateAndGetPayloadCallback($mutateAndGetPayload)])",
36 2
        ];
37
    }
38
39 2 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...
40
    {
41 2
        if (is_string($mutateAndGetPayload) &&  0 === strpos($mutateAndGetPayload, '@=')) {
42 2
            $cleanMutateAndGetPayload = substr($mutateAndGetPayload, 2);
43 2
        } else {
44 1
            $cleanMutateAndGetPayload = json_encode($mutateAndGetPayload);
45
        }
46
47 2
        return $cleanMutateAndGetPayload;
48
    }
49
}
50