Test Setup Failed
Push — master ( 435315...25317c )
by Kirill
02:05
created

EnumTypeBuilder::getValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Adapters\Webonyx\Builder;
11
12
use GraphQL\Type\Definition\EnumType;
13
use Railt\Reflection\Abstraction\EnumTypeInterface;
14
use Railt\Reflection\Abstraction\EnumValueInterface;
15
16
/**
17
 * Class EnumTypeBuilder
18
 *
19
 * @package Railt\Adapters\Webonyx\Builder
20
 * @property-read EnumTypeInterface $type
21
 */
22
class EnumTypeBuilder extends Builder
23
{
24
    /**
25
     * @return EnumType
26
     */
27
    public function build()
28
    {
29
        return new EnumType([
30
            'name'        => $this->type->getName(),
31
            'description' => $this->type->getDescription(),
0 ignored issues
show
Bug introduced by
The method getDescription() does not seem to exist on object<Railt\Reflection\...tion\EnumTypeInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
            'values'      => iterator_to_array($this->getValues()),
33
        ]);
34
    }
35
36
    /**
37
     * @return \Traversable
38
     */
39
    private function getValues(): \Traversable
40
    {
41
        foreach ($this->type->getValues() as $enumValue) {
42
            yield $enumValue->getName() => [
43
                'value'       => $enumValue->getName(),
44
                'description' => $enumValue->getDescription(),
45
            ];
46
        }
47
    }
48
}
49
50