Test Setup Failed
Push — master ( 050b68...43996d )
by Kirill
03:02
created

TypeDefinitionContext::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
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\Backend\Context;
13
14
use Railt\SDL\Frontend\Ast\Definition\Type\TypeDefinitionNode;
15
use Railt\SDL\Frontend\Ast\Identifier;
16
use Railt\SDL\Frontend\Ast\Node;
17
18
/**
19
 * @property-read TypeDefinitionNode $ast
20
 */
21
abstract class TypeDefinitionContext extends DefinitionContext
22
{
23
    /**
24
     * @var string
25
     */
26
    protected string $name;
27
28
    /**
29
     * @var array|string[]
30
     */
31
    protected array $args;
32
33
    /**
34
     * TypeDefinitionContext constructor.
35
     *
36
     * @param TypeDefinitionNode $ast
37
     */
38
    public function __construct(TypeDefinitionNode $ast)
39
    {
40
        parent::__construct($ast);
41
42
        $this->name = $ast->name->value;
43
        $this->args = \array_map(fn (Identifier $id) => $id->value, $ast->name->arguments);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getName(): string
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * @return array|string[]
56
     */
57
    public function getGenericArguments(): array
58
    {
59
        return $this->args;
60
    }
61
}
62