UnionTypeDefinitionNode   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 15
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 21 5
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\Description;
15
use Railt\SDL\Frontend\Ast\Executable\DirectiveNode;
16
use Railt\SDL\Frontend\Ast\Node;
17
18
/**
19
 * Class UnionTypeDefinitionNode
20
 */
21
class UnionTypeDefinitionNode extends TypeDefinitionNode
22
{
23
    /**
24
     * @var UnionMemberNode[]
25
     */
26
    public array $types = [];
27
28
    /**
29
     * @param array|Node[] $children
30
     * @return static
31
     */
32
    public static function create(array $children): self
33
    {
34
        $union = new static($children[1]);
35
36
        foreach ($children as $child) {
37
            switch (true) {
38
                case $child instanceof Description:
39
                    $union->description = $child->value;
40
                    break;
41
42
                case $child instanceof DirectiveNode:
43
                    $union->directives[] = $child;
44
                    break;
45
46
                case $child instanceof UnionMemberNode:
0 ignored issues
show
Bug introduced by
The type Railt\SDL\Frontend\Ast\D...on\Type\UnionMemberNode 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...
47
                    $union->types[] = $child;
48
                    break;
49
            }
50
        }
51
52
        return $union;
53
    }
54
}
55