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 (#563)
by Jérémiah
21:06 queued 14:50
created

MutationFieldResolver::setObjectOrArrayValue()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.576

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 3.576
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 9
    public function __construct(PromiseAdapter $promiseAdapter, ArgumentFactory $argumentFactory)
19
    {
20 9
        $this->promiseAdapter = $promiseAdapter;
21 9
        $this->argumentFactory = $argumentFactory;
22 9
    }
23
24 7
    public function __invoke($args, $context, $info, \Closure $mutateAndGetPayloadCallback)
25
    {
26 7
        $input = $this->argumentFactory->create($args['input']);
27
28 7
        return $this->promiseAdapter->createFulfilled($mutateAndGetPayloadCallback($input, $context, $info))
29
            ->then(function ($payload) use ($input) {
30 7
                $this->setObjectOrArrayValue($payload, 'clientMutationId', $input['clientMutationId']);
31
32 7
                return $payload;
33 7
            });
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 35
    public static function getAliases(): array
40
    {
41 35
        return ['__invoke' => 'relay_mutation_field'];
42
    }
43
44 7
    private function setObjectOrArrayValue(&$objectOrArray, $fieldName, $value): void
45
    {
46 7
        if (\is_array($objectOrArray)) {
47 7
            $objectOrArray[$fieldName] = $value;
48
        } elseif (\is_object($objectOrArray)) {
49
            $objectOrArray->$fieldName = $value;
50
        }
51 7
    }
52
}
53