Passed
Push — master ( e52344...df819b )
by Rafael
09:21
created

EnumDefinitionType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 21
c 0
b 0
f 0
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Type\Definition;
12
13
use GraphQL\Type\Definition\EnumType;
14
use Ynlo\GraphQLBundle\Definition\EnumDefinition;
15
16
/**
17
 * Class EnumDefinitionType
18
 */
19
class EnumDefinitionType extends EnumType
20
{
21
    /**
22
     * @param EnumDefinition $definition
23
     */
24 1
    public function __construct(EnumDefinition $definition)
25
    {
26 1
        $values = [];
27 1
        foreach ($definition->getValues() as $value) {
28 1
            $name = $value->getName();
29 1
            $values[$name] = [
30 1
                'value' => $value->getValue(),
31 1
                'description' => $value->getDescription(),
32 1
                'deprecationReason' => $value->getDeprecationReason(),
33
            ];
34
        }
35 1
        parent::__construct(
36
            [
37 1
                'name' => $definition->getName(),
38 1
                'description' => $definition->getDescription(),
39 1
                'values' => $values,
40
            ]
41
        );
42 1
    }
43
}
44