Repetition::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 2
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\Repetition as RepetitionRule;
13
use Railt\Parser\Rule\Rule;
14
15
/**
16
 * Class Repetition
17
 */
18
class Repetition extends AbstractBuilder
19
{
20
    /**
21
     * @var int
22
     */
23
    private $min;
24
25
    /**
26
     * @var int
27
     */
28
    private $max;
29
30
    /**
31
     * Repetition constructor.
32
     * @param $name
33
     * @param int $min
34
     * @param int $max
35
     * @param $children
36
     * @param string|null $nodeId
37
     */
38
    public function __construct($name, int $min, int $max, $children, string $nodeId = null)
39
    {
40
        $this->min = $min;
41
        $this->max = $max;
42
        parent::__construct($name, $children, $nodeId);
43
    }
44
45
    /**
46
     * @return Rule|RepetitionRule
47
     */
48 View Code Duplication
    public function build(): Rule
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $rule = new RepetitionRule($this->name, $this->min, $this->max, $this->children, $this->nodeId);
51
        $rule->setDefaultId($this->defaultId);
52
53
        return $rule;
54
    }
55
}
56