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

DependentDefinitionBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildType() 0 16 4
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\Type;
13
use Railt\Reflection\Contracts\Behavior\AllowsTypeIndication;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Contrac...or\AllowsTypeIndication 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...
14
15
/**
16
 * @property AllowsTypeIndication $reflection
17
 */
18
abstract class DependentDefinitionBuilder extends TypeBuilder
19
{
20
    /**
21
     * @return Type
22
     * @throws \InvalidArgumentException
23
     */
24
    protected function buildType(): Type
25
    {
26
        /** @var Type $result */
27
        $type = $this->load($this->reflection->getTypeDefinition());
28
29
        if ($this->reflection->isListOfNonNulls()) {
30
            $type = Type::listOf(Type::nonNull($type));
31
        } elseif ($this->reflection->isList()) {
32
            $type = Type::listOf($type);
33
        }
34
35
        if ($this->reflection->isNonNull()) {
36
            $type = Type::nonNull($type);
37
        }
38
39
        return $type;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $type could return the type GraphQL\Type\Definition\Directive which is incompatible with the type-hinted return GraphQL\Type\Definition\Type. Consider adding an additional type-check to rule them out.
Loading history...
40
    }
41
}
42