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 (#4)
by Jérémiah
06:39
created

MutationField::toFieldDefinition()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 3
Bugs 2 Features 2
Metric Value
c 3
b 2
f 2
dl 0
loc 34
ccs 0
cts 29
cp 0
rs 8.8571
cc 2
eloc 23
nc 2
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 GraphQL\Type\Definition\Type;
16
use GraphQL\Utils;
17
use Overblog\GraphQLBundle\Definition\FieldInterface;
18
use Overblog\GraphQLBundle\Definition\MergeFieldTrait;
19
20
class MutationField implements FieldInterface
21
{
22
    use MergeFieldTrait;
23
24
    public function toFieldDefinition(array $config)
25
    {
26
        Utils::invariant(!empty($config['name']), 'Every type is expected to have name');
27
28
        Config::validate($config, [
29
            'name' => Config::STRING | Config::REQUIRED,
30
            'mutateAndGetPayload' => Config::CALLBACK | Config::REQUIRED,
31
            'payloadType' => Config::OBJECT_TYPE | Config::CALLBACK | Config::REQUIRED,
32
            'inputType' => Config::INPUT_TYPE | Config::CALLBACK | Config::REQUIRED,
33
            'description' => Config::STRING,
34
        ]);
35
36
        $name = $config['name'];
37
38
        $mutateAndGetPayload = $config['mutateAndGetPayload'];
39
        $description = isset($config['description']) ? $config['description'] : null;
40
        $payloadType = $config['payloadType'];
41
        $inputType = $config['inputType'];
42
43
        return [
44
            'name' => $name,
45
            'description' => $description,
46
            'type' => $payloadType,
47
            'args' => [
48
                'input' => ['type' => Type::nonNull($inputType)],
49
            ],
50
            'resolve' => function ($_, $input, $info) use ($mutateAndGetPayload, $name) {
51
                $payload = $mutateAndGetPayload($input['input'], $info);
52
                $payload['clientMutationId'] = $input['input']['clientMutationId'];
53
54
                return $payload;
55
            },
56
        ];
57
    }
58
}
59