Completed
Push — master ( 3b79f3...426227 )
by Kirill
03:11
created

ObjectBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 9 1
A buildInterfaces() 0 9 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\Builders;
11
12
use GraphQL\Type\Definition\ObjectType;
13
use GraphQL\Type\Definition\Type;
14
use Railt\Reflection\Contracts\Definitions\ObjectDefinition;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Contrac...itions\ObjectDefinition was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * @property ObjectDefinition $reflection
18
 */
19
class ObjectBuilder extends TypeBuilder
20
{
21
    /**
22
     * @return Type
23
     * @throws \InvalidArgumentException
24
     */
25
    public function build(): Type
26
    {
27
        return new ObjectType([
28
            'name'        => $this->reflection->getName(),
29
            'description' => $this->reflection->getDescription(),
30
            'fields'      => function (): array {
31
                return FieldBuilder::buildFields($this->reflection, $this->getRegistry());
32
            },
33
            'interfaces'  => $this->buildInterfaces(),
34
        ]);
35
    }
36
37
    /**
38
     * @return array
39
     * @throws \InvalidArgumentException
40
     */
41
    private function buildInterfaces(): array
42
    {
43
        $result = [];
44
45
        foreach ($this->reflection->getInterfaces() as $interface) {
46
            $result[] = $this->load($interface);
47
        }
48
49
        return $result;
50
    }
51
}
52