OperationTypeDefinitionNode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 5 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;
13
14
use Railt\SDL\Frontend\Ast\DefinitionNode;
15
use Railt\SDL\Frontend\Ast\Node;
16
use Railt\SDL\Frontend\Ast\Type\NamedTypeNode;
17
18
/**
19
 * Class OperationTypeDefinitionNode
20
 *
21
 * <code>
22
 *  export interface OperationTypeDefinitionNode {
23
 *      readonly kind: 'OperationTypeDefinition';
24
 *      readonly loc?: Location;
25
 *      readonly operation: OperationTypeNode;
26
 *      readonly type: NamedTypeNode;
27
 *  }
28
 * </code>
29
 */
30
class OperationTypeDefinitionNode extends DefinitionNode
31
{
32
    /**
33
     * @var string
34
     */
35
    public string $operation;
36
37
    /**
38
     * @var NamedTypeNode
39
     */
40
    public NamedTypeNode $type;
41
42
    /**
43
     * OperationTypeDefinitionNode constructor.
44
     *
45
     * @param string $operation
46
     * @param NamedTypeNode $type
47
     */
48
    public function __construct(string $operation, NamedTypeNode $type)
49
    {
50
        $this->operation = $operation;
51
        $this->type = $type;
52
    }
53
54
    /**
55
     * @param array|Node[] $children
56
     * @return static
57
     */
58
    public static function create(array $children): self
59
    {
60
        return new static(
61
            $children[0]->getValue(),
62
            $children[1]
63
        );
64
    }
65
}
66