State::isReduceOnly()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * This file is part of PHP-Yacc 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 PhpYacc\Grammar;
11
12
use PhpYacc\Lalr\Conflict;
13
use PhpYacc\Lalr\Lr1;
14
use PhpYacc\Lalr\Reduce;
15
16
/**
17
 * Class State.
18
 */
19
class State
20
{
21
    /**
22
     * @var array|State[]
23
     */
24
    public $shifts = [];
25
26
    /**
27
     * @var array|Reduce[]
28
     */
29
    public $reduce;
30
31
    /**
32
     * @var Conflict|null
33
     */
34
    public $conflict;
35
36
    /**
37
     * @var Symbol
38
     */
39
    public $through;
40
41
    /**
42
     * @var Lr1
43
     */
44
    public $items;
45
46
    /**
47
     * @var int
48
     */
49
    public $number;
50
51
    /**
52
     * State constructor.
53
     *
54
     * @param Symbol $through
55
     * @param Lr1    $items
56
     */
57
    public function __construct(Symbol $through, Lr1 $items)
58
    {
59
        $this->through = $through;
60
        $this->items = $items;
61
    }
62
63
    /**
64
     * @return bool
65
     */
66
    public function isReduceOnly(): bool
67
    {
68
        return empty($this->shifts) && $this->reduce[0]->symbol->isNilSymbol();
69
    }
70
}
71