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 — 0.11 (#435)
by Jérémiah
13:02
created

EnumTypeDefinition::getDefinition()   A

Complexity

Conditions 5
Paths 1

Size

Total Lines 44
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 31
CRAP Score 5

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 44
ccs 31
cts 31
cp 1
rs 9.1128
c 0
b 0
f 0
cc 5
nc 1
nop 0
crap 5
1
<?php
2
3
namespace Overblog\GraphQLBundle\Config;
4
5
class EnumTypeDefinition extends TypeDefinition
6
{
7 37
    public function getDefinition()
8
    {
9 37
        $node = self::createNode('_enum_config');
10
11
        $node
12 37
            ->children()
13 37
                ->append($this->nameSection())
14 37
                ->arrayNode('values')
15 37
                    ->useAttributeAsKey('name')
16 37
                    ->beforeNormalization()
17
                        ->ifTrue(function ($v) {
18 4
                            return \is_array($v);
19 37
                        })
20
                        ->then(function ($v) {
21 4
                            foreach ($v as $name => &$options) {
22
                                // short syntax NAME: VALUE
23 4
                                if (!\is_null($options) && !\is_array($options)) {
24 2
                                    $options = ['value' => $options];
25
                                }
26
27
                                // use name as value if no value given
28 4
                                if (!\array_key_exists('value', $options)) {
0 ignored issues
show
Bug introduced by
It seems like $options can also be of type null; however, parameter $search of array_key_exists() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
                                if (!\array_key_exists('value', /** @scrutinizer ignore-type */ $options)) {
Loading history...
29 4
                                    $options['value'] = $name;
30
                                }
31
                            }
32
33 4
                            return $v;
34 37
                        })
35 37
                    ->end()
36 37
                    ->prototype('array')
37 37
                        ->isRequired()
38 37
                        ->children()
39 37
                            ->scalarNode('value')->isRequired()->end()
40 37
                            ->append($this->descriptionSection())
41 37
                            ->append($this->deprecationReasonSelection())
42 37
                        ->end()
43 37
                    ->end()
44 37
                    ->isRequired()
45 37
                    ->requiresAtLeastOneElement()
46 37
                ->end()
47 37
                ->append($this->descriptionSection())
48 37
            ->end();
49
50 37
        return $node;
51
    }
52
}
53