Completed
Pull Request — master (#204)
by Ryan
11:34
created

KpiStatusType   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 20
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2015–2018 Alexandr Viniychuk <http://youshido.com>.
4
 * Copyright (c) 2015–2018 Portey Vasil <https://github.com/portey>.
5
 * Copyright (c) 2018 Ryan Parman <https://github.com/skyzyx>.
6
 * Copyright (c) 2018 Ashley Hutson <https://github.com/asheliahut>.
7
 * Copyright (c) 2015–2018 Contributors.
8
 *
9
 * http://opensource.org/licenses/MIT
10
 */
11
12
declare(strict_types=1);
13
14
namespace Youshido\Tests\Issues\Issue171;
15
16
use Youshido\GraphQL\Config\Schema\SchemaConfig;
17
use Youshido\GraphQL\Schema\AbstractSchema;
18
use Youshido\GraphQL\Type\Enum\AbstractEnumType;
19
use Youshido\GraphQL\Type\Object\AbstractObjectType;
20
21
class Issue171Schema extends AbstractSchema
22
{
23
    public function build(SchemaConfig $config): void
24
    {
25
        $config->getQuery()->addField(
26
            'plan',
27
            [
28
                'type' => new PlanType(),
29
            ]
30
        );
31
    }
32
}
33
34
class PlanType extends AbstractObjectType
35
{
36
    public function build($config): void
37
    {
38
        $config->addField('kpi_status', [
39
            'type' => new KpiStatusType(),
40
        ]);
41
    }
42
}
43
44
class KpiStatusType extends AbstractEnumType
45
{
46
    public function getValues()
47
    {
48
        return [
49
            [
50
                'name'  => 'BAD',
51
                'value' => 'Bad',
52
            ],
53
            [
54
                'name'  => 'GOOD',
55
                'value' => 'Good',
56
            ],
57
            [
58
                'name'  => 'WARNING',
59
                'value' => 'Warning',
60
            ],
61
        ];
62
    }
63
}
64