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 (#197)
by Renato
09:16 queued 02:55
created

Resolver::setObjectOrArrayValue()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 5
Ratio 50 %

Code Coverage

Tests 5
CRAP Score 4.3731

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 5
loc 10
ccs 5
cts 7
cp 0.7143
rs 9.2
c 1
b 0
f 0
cc 4
eloc 6
nc 3
nop 3
crap 4.3731
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 34
    public static function defaultResolveFn($objectOrArray, $args, $context, ResolveInfo $info)
26
    {
27 34
        $fieldName = $info->fieldName;
28 34
        $value = static::valueFromObjectOrArray($objectOrArray, $fieldName);
29
30 34
        return $value instanceof \Closure ? $value($objectOrArray, $args, $context, $info) : $value;
31
    }
32
33 35
    public static function valueFromObjectOrArray($objectOrArray, $fieldName)
34
    {
35 35
        $value = null;
36 35
        $index = sprintf('[%s]', $fieldName);
37
38 35 View Code Duplication
        if (self::isReadable($objectOrArray, $index)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39 29
            $value = self::getAccessor()->getValue($objectOrArray, $index);
40 19
        } elseif (is_object($objectOrArray) && self::isReadable($objectOrArray, $fieldName)) {
41 17
            $value = self::getAccessor()->getValue($objectOrArray, $fieldName);
42
        }
43
44 35
        return $value;
45
    }
46
47 5
    public static function setObjectOrArrayValue(&$objectOrArray, $fieldName, $value)
48
    {
49 5
        $index = sprintf('[%s]', $fieldName);
50
51 5 View Code Duplication
        if (self::isWritable($objectOrArray, $index)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52 5
            self::getAccessor()->setValue($objectOrArray, $index, $value);
53
        } elseif (is_object($objectOrArray) && self::isWritable($objectOrArray, $fieldName)) {
54
            self::getAccessor()->setValue($objectOrArray, $fieldName, $value);
55
        }
56 5
    }
57
58 35
    private static function isReadable($objectOrArray, $indexOrProperty)
59
    {
60 35
        return self::getAccessor()->isReadable($objectOrArray, $indexOrProperty);
61
    }
62
63 5
    private static function isWritable($objectOrArray, $indexOrProperty)
64
    {
65 5
        return self::getAccessor()->isWritable($objectOrArray, $indexOrProperty);
66
    }
67
68 35
    private static function getAccessor()
69
    {
70 35
        if (null === self::$accessor) {
71 1
            self::$accessor = PropertyAccess::createPropertyAccessor();
72
        }
73
74 35
        return self::$accessor;
75
    }
76
}
77