InterfaceTypeDefinitionNode::create()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 25
rs 9.1111
c 0
b 0
f 0
cc 6
nc 6
nop 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Frontend\Ast\Definition\Type;
13
14
use Railt\SDL\Frontend\Ast\Definition\FieldDefinitionNode;
15
use Railt\SDL\Frontend\Ast\Description;
16
use Railt\SDL\Frontend\Ast\Executable\DirectiveNode;
17
use Railt\SDL\Frontend\Ast\Node;
18
use Railt\SDL\Frontend\Ast\Type\NamedTypeNode;
19
20
/**
21
 * Class InterfaceTypeDefinitionNode
22
 *
23
 * <code>
24
 *  export interface InterfaceTypeDefinitionNode {
25
 *      readonly kind: 'InterfaceTypeDefinition';
26
 *      readonly loc?: Location;
27
 *      readonly description?: StringValueNode;
28
 *      readonly name: IdentifierNode;
29
 *      readonly interfaces?: ReadonlyArray<NamedTypeNode>;
30
 *      readonly directives?: ReadonlyArray<DirectiveNode>;
31
 *      readonly fields?: ReadonlyArray<FieldDefinitionNode>;
32
 *  }
33
 * </code>
34
 */
35
class InterfaceTypeDefinitionNode extends TypeDefinitionNode
36
{
37
    /**
38
     * @var ImplementedInterfaceNode[]
39
     */
40
    public array $interfaces = [];
41
42
    /**
43
     * @var FieldDefinitionNode[]
44
     */
45
    public array $fields = [];
46
47
    /**
48
     * @param array|Node[] $children
49
     * @return static
50
     */
51
    public static function create(array $children): self
52
    {
53
        $interface = new static($children[1]);
54
55
        foreach ($children as $child) {
56
            switch (true) {
57
                case $child instanceof Description:
58
                    $interface->description = $child->value;
59
                    break;
60
61
                case $child instanceof FieldDefinitionNode:
62
                    $interface->fields[] = $child;
63
                    break;
64
65
                case $child instanceof DirectiveNode:
66
                    $interface->directives[] = $child;
67
                    break;
68
69
                case $child instanceof ImplementedInterfaceNode:
0 ignored issues
show
Bug introduced by
The type Railt\SDL\Frontend\Ast\D...mplementedInterfaceNode 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...
70
                    $interface->interfaces[] = $child;
71
                    break;
72
            }
73
        }
74
75
        return $interface;
76
    }
77
}
78