1<?php
2
3declare(strict_types=1);
4
5namespace Antlr\Antlr4\Runtime\Atn\Transitions;
6
7use Antlr\Antlr4\Runtime\Atn\States\ATNState;
8use Antlr\Antlr4\Runtime\IntervalSet;
9
10final class AtomTransition extends Transition
11{
12    /** @var int */
13    public $label;
14
15    public function __construct(ATNState $target, int $label)
16    {
17        parent::__construct($target);
18
19        $this->label = $label;
20    }
21
22    public function label() : ?IntervalSet
23    {
24        return IntervalSet::fromInt($this->label);
25    }
26
27    public function matches(int $symbol, int $minVocabSymbol, int $maxVocabSymbol) : bool
28    {
29        return $this->label === $symbol;
30    }
31
32    public function getSerializationType() : int
33    {
34        return self::ATOM;
35    }
36
37    public function equals(object $other) : bool
38    {
39        if ($this === $other) {
40            return true;
41        }
42
43        return $other instanceof self
44            && $this->label === $other->label
45            && $this->target->equals($other->target);
46    }
47
48    public function __toString() : string
49    {
50        return (string) $this->label;
51    }
52}
53