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

InputTypeBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 10 1
A getInputFields() 0 6 2
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\InputObjectType;
13
use Railt\Reflection\Abstraction\InputTypeInterface;
14
15
/**
16
 * Class InputTypeBuilder
17
 *
18
 * @package Railt\Adapters\Webonyx\Builder
19
 * @property-read InputTypeInterface $type
20
 */
21
class InputTypeBuilder extends Builder
22
{
23
    /**
24
     * @return InputObjectType
25
     * @throws \LogicException
26
     */
27
    public function build()
28
    {
29
        return new InputObjectType([
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\...ion\InputTypeInterface>.

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
            'fields'       => function (): array {
33
                return iterator_to_array($this->getInputFields());
34
            }
35
        ]);
36
    }
37
38
    /**
39
     * @return \Traversable
40
     * @throws \LogicException
41
     */
42
    private function getInputFields(): \Traversable
43
    {
44
        foreach ($this->type->getArguments() as $argument) {
45
            yield $argument->getName() => $this->make($argument, FieldBuilder::class);
46
        }
47
    }
48
}
49