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
Push — master ( 48eab4...bce55d )
by Jérémiah
14:36
created

FieldsNode::toConfig()   B

Complexity

Conditions 6
Paths 2

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 14
cts 14
cp 1
rs 8.8817
c 0
b 0
f 0
cc 6
nc 2
nop 2
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Config\Parser\GraphQL\ASTConverter;
6
7
use GraphQL\Language\AST\Node;
8
use GraphQL\Language\AST\NodeKind;
9
use GraphQL\Language\AST\ValueNode;
10
11
class FieldsNode implements NodeInterface
12
{
13 2
    public static function toConfig(Node $node, $property = 'fields'): array
14
    {
15 2
        $config = [];
16 2
        if (!empty($node->$property)) {
17 2
            foreach ($node->$property as $definition) {
18 2
                $fieldConfig = TypeNode::toConfig($definition) + DescriptionNode::toConfig($definition);
19
20 2
                if (!empty($definition->arguments)) {
21 2
                    $fieldConfig['args'] = self::toConfig($definition, 'arguments');
22
                }
23
24 2
                if (!empty($definition->defaultValue)) {
25 1
                    $fieldConfig['defaultValue'] = self::astValueNodeToConfig($definition->defaultValue);
26
                }
27
28 2
                $directiveConfig = DirectiveNode::toConfig($definition);
29 2
                if (isset($directiveConfig['deprecationReason'])) {
30 1
                    $fieldConfig['deprecationReason'] = $directiveConfig['deprecationReason'];
31
                }
32
33 2
                $config[$definition->name->value] = $fieldConfig;
34
            }
35
        }
36
37 2
        return $config;
38
    }
39
40 1
    private static function astValueNodeToConfig(ValueNode $valueNode)
41
    {
42 1
        $config = null;
43 1
        switch ($valueNode->kind) {
44
            case NodeKind::INT:
45
            case NodeKind::FLOAT:
46
            case NodeKind::STRING:
47
            case NodeKind::BOOLEAN:
48
            case NodeKind::ENUM:
49 1
                $config = $valueNode->value;
50 1
                break;
51
52
            case NodeKind::LST:
53 1
                $config = [];
54 1
                foreach ($valueNode->values as $node) {
55 1
                    $config[] = self::astValueNodeToConfig($node);
56
                }
57 1
                break;
58
59
            case NodeKind::NULL:
60 1
                $config = null;
61 1
                break;
62
        }
63
64 1
        return $config;
65
    }
66
}
67