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
18:50
created

Resolver::isReadable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Resolver;
6
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
class Resolver
10
{
11 42
    public static function defaultResolveFn($objectOrArray, $args, $context, ResolveInfo $info)
12
    {
13 42
        $fieldName = $info->fieldName;
14 42
        $value = static::valueFromObjectOrArray($objectOrArray, $fieldName);
15
16 42
        return $value instanceof \Closure ? $value($objectOrArray, $args, $context, $info) : $value;
17
    }
18
19 43
    public static function valueFromObjectOrArray($objectOrArray, $fieldName)
20
    {
21 43
        $value = null;
22 43
        if (\is_array($objectOrArray) && isset($objectOrArray[$fieldName])) {
23 36
            $value = $objectOrArray[$fieldName];
24 21
        } elseif (\is_object($objectOrArray)) {
25 19
            if (null !== $getter = self::guessObjectMethod($objectOrArray, $fieldName, 'get')) {
26 17
                $value = $objectOrArray->$getter();
27 2
            } elseif (isset($objectOrArray->$fieldName)) {
28 1
                $value = $objectOrArray->$fieldName;
29
            }
30
        }
31
32 43
        return $value;
33
    }
34
35 8
    public static function setObjectOrArrayValue(&$objectOrArray, $fieldName, $value): void
36
    {
37 8
        if (\is_array($objectOrArray)) {
38 8
            $objectOrArray[$fieldName] = $value;
39 1
        } elseif (\is_object($objectOrArray)) {
40 1
            $objectOrArray->$fieldName = $value;
41
        }
42 8
    }
43
44 19
    private static function guessObjectMethod($object, string $fieldName, string $prefix): ?string
45
    {
46 19
        if (\is_callable([$object, $method = $prefix.\str_replace(' ', '', \ucwords(\str_replace('_', ' ', $fieldName)))])) {
47 17
            return $method;
48
        }
49
50 2
        return null;
51
    }
52
}
53