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
Pull Request — master (#563)
by Jérémiah
20:34
created

MutationFieldResolver::setObjectOrArrayValue()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 3
nc 3
nop 3
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\GraphQL\Relay\Mutation;
6
7
use GraphQL\Executor\Promise\PromiseAdapter;
8
use Overblog\GraphQLBundle\Definition\ArgumentFactory;
9
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
10
use Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface;
11
12
final class MutationFieldResolver implements ResolverInterface, AliasedInterface
13
{
14
    private $promiseAdapter;
15
16
    private $argumentFactory;
17
18
    public function __construct(PromiseAdapter $promiseAdapter, ArgumentFactory $argumentFactory)
19 9
    {
20
        $this->promiseAdapter = $promiseAdapter;
21 9
        $this->argumentFactory = $argumentFactory;
22 9
    }
23 9
24
    public function __invoke($args, $context, $info, \Closure $mutateAndGetPayloadCallback)
25 7
    {
26
        $input = $this->argumentFactory->create($args['input']);
27 7
28
        return $this->promiseAdapter->createFulfilled($mutateAndGetPayloadCallback($input, $context, $info))
29 7
            ->then(function ($payload) use ($input) {
30
                $this->setObjectOrArrayValue($payload, 'clientMutationId', $input['clientMutationId']);
31 7
32
                return $payload;
33 7
            });
34 7
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public static function getAliases(): array
40 35
    {
41
        return ['__invoke' => 'relay_mutation_field'];
42 35
    }
43
44
    private function setObjectOrArrayValue(&$objectOrArray, $fieldName, $value): void
45
    {
46
        if (\is_array($objectOrArray)) {
47
            $objectOrArray[$fieldName] = $value;
48
        } elseif (\is_object($objectOrArray)) {
49
            $objectOrArray->$fieldName = $value;
50
        }
51
    }
52
}
53