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 ( d6c7a2...be250e )
by Jérémiah
36s
created

Resolver::valueFromObjectOrArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
crap 3
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\Resolver;
13
14
use GraphQL\Type\Definition\ResolveInfo;
15
use Symfony\Component\PropertyAccess\PropertyAccess;
16
use Symfony\Component\PropertyAccess\PropertyAccessor;
17
18
class Resolver
19
{
20
    /**
21
     * @var PropertyAccessor
22
     */
23
    private static $accessor;
24
25 30
    public static function defaultResolveFn($objectOrArray, $args, ResolveInfo $info)
26
    {
27 30
        $fieldName = $info->fieldName;
28 30
        $value = static::valueFromObjectOrArray($objectOrArray, $fieldName);
29
30 30
        return $value instanceof \Closure ? $value($objectOrArray, $args, $info) : $value;
31
    }
32
33 31
    public static function valueFromObjectOrArray($objectOrArray, $fieldName)
34
    {
35 31
        $value = null;
36 31
        $index = sprintf('[%s]', $fieldName);
37
38 31
        if (self::getAccessor()->isReadable($objectOrArray, $index)) {
39 19
            $value = self::getAccessor()->getValue($objectOrArray, $index);
40 31
        } elseif (is_object($objectOrArray)) {
41 17
            $value = self::propertyValueFromObject($objectOrArray, $fieldName);
42 17
        }
43
44 31
        return $value;
45
    }
46
47 2
    public static function setObjectOrArrayValue(&$objectOrArray, $fieldName, $value)
48
    {
49 2
        $index = sprintf('[%s]', $fieldName);
50
51 2
        if (self::getAccessor()->isWritable($objectOrArray, $index)) {
52 2
            self::getAccessor()->setValue($objectOrArray, $index, $value);
53 2
        } elseif (is_object($objectOrArray)) {
54
            self::getAccessor()->setValue($objectOrArray, $fieldName, $value);
55
        }
56 2
    }
57
58 17
    private static function propertyValueFromObject($object, $fieldName)
59
    {
60 17
        $value = null;
61
62 17
        if (self::getAccessor()->isReadable($object, $fieldName)) {
63 16
            $value = self::getAccessor()->getValue($object, $fieldName);
64 16
        }
65
66 17
        return $value;
67
    }
68
69 31
    private static function getAccessor()
70
    {
71 31
        if (null === self::$accessor) {
72 1
            self::$accessor = PropertyAccess::createPropertyAccessor();
73 1
        }
74
75 31
        return self::$accessor;
76
    }
77
}
78