AbstractBuilder::build()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Compiler\Grammar\Builder;
11
12
use Railt\Parser\Rule\Rule;
13
14
/**
15
 * Class AbstractBuilder
16
 */
17
abstract class AbstractBuilder
18
{
19
    /**
20
     * @var int|string
21
     */
22
    protected $name;
23
24
    /**
25
     * @var string|null
26
     */
27
    protected $nodeId;
28
29
    /**
30
     * @var string|null
31
     */
32
    protected $defaultId;
33
34
    /**
35
     * @var int|int[]|string|string[]
36
     */
37
    protected $children;
38
39
    /**
40
     * Rule constructor.
41
     * @param string|int $name Rule name.
42
     * @param int|int[]|string|string[] $children Children.
43
     * @param string $nodeId Node ID.
44
     */
45
    public function __construct($name, $children, string $nodeId = null)
46
    {
47
        $this->name     = $name;
48
        $this->children = $children;
49
        $this->nodeId   = $nodeId;
50
    }
51
52
    /**
53
     * @param $name
54
     */
55
    public function setName($name): void
56
    {
57
        $this->name = $name;
58
    }
59
60
    /**
61
     * @return Rule
62
     */
63
    abstract public function build(): Rule;
64
65
    /**
66
     * @param $nodeId
67
     */
68
    public function setNodeId($nodeId): void
69
    {
70
        $this->nodeId = $nodeId;
71
    }
72
73
    /**
74
     * @param $defaultNodeId
75
     */
76
    public function setDefaultId($defaultNodeId): void
77
    {
78
        $this->defaultId = $defaultNodeId;
79
    }
80
}
81