Passed
Push — master ( 81686d...1595cb )
by Kirill
04:41
created

NonNullTypeNode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 3 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\Type;
13
14
use Railt\SDL\Frontend\Ast\Node;
15
16
/**
17
 * Class NonNullTypeNode
18
 *
19
 * <code>
20
 *  export interface NonNullTypeNode {
21
 *      readonly kind: 'NonNullType';
22
 *      readonly loc?: Location;
23
 *      readonly type: NamedTypeNode | ListTypeNode;
24
 *  }
25
 * </code>
26
 */
27
class NonNullTypeNode extends TypeNode
28
{
29
    /**
30
     * @var TypeNode
31
     */
32
    public TypeNode $type;
33
34
    /**
35
     * NonNullTypeNode constructor.
36
     *
37
     * @param TypeNode $type
38
     */
39
    public function __construct(TypeNode $type)
40
    {
41
        \assert(! $type instanceof self);
42
43
        $this->type = $type;
44
    }
45
46
    /**
47
     * @param array|Node[] $children
48
     * @return static
49
     */
50
    public static function create(array $children): self
51
    {
52
        return new static($children[0]);
53
    }
54
}
55