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

UnionTypeBuilder::getUnionTypes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
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\UnionType;
13
use Railt\Reflection\Abstraction\UnionTypeInterface;
14
15
/**
16
 * Class UnionTypeBuilder
17
 *
18
 * @package Railt\Adapters\Webonyx\Builder
19
 * @property-read UnionTypeInterface $type
20
 */
21
class UnionTypeBuilder extends Builder
22
{
23
    /**
24
     * TODO Implement later
25
     *
26
     * @return UnionType
27
     */
28
    public function build()
29
    {
30
        return new UnionType([
31
            'name'        => $this->type->getName(),
32
            'description' => $this->type->getDescription(),
0 ignored issues
show
Bug introduced by
The method getDescription() does not seem to exist on object<Railt\Reflection\...ion\UnionTypeInterface>.

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...
33
            'types'       => function() {
34
                return iterator_to_array($this->getUnionTypes());
35
            },
36
            'resolveType' => function ($value) {
37
                dd($value);
38
            }
39
        ]);
40
    }
41
42
    /**
43
     * @return \Traversable
44
     */
45
    private function getUnionTypes(): \Traversable
46
    {
47
        foreach ($this->type->getTypes() as $relation) {
48
            yield $relation->getName() => $this->resolve($relation->getName());
49
        }
50
    }
51
}
52