1<?php
2
3declare(strict_types=1);
4
5namespace Antlr\Antlr4\Runtime\Atn;
6
7final class ATNDeserializationOptions
8{
9    /** @var bool */
10    private $readOnly = false;
11
12    /** @var bool */
13    private $verifyATN;
14
15    /** @var bool */
16    private $generateRuleBypassTransitions;
17
18    public static function defaultOptions() : ATNDeserializationOptions
19    {
20        static $defaultOptions;
21
22        if ($defaultOptions === null) {
23            $defaultOptions = new ATNDeserializationOptions();
24            $defaultOptions->readOnly = true;
25        }
26
27        return $defaultOptions;
28    }
29
30    public function __construct(?ATNDeserializationOptions $options = null)
31    {
32        $this->verifyATN = $options === null ? true : $options->verifyATN;
33        $this->generateRuleBypassTransitions = $options === null ? false : $options->generateRuleBypassTransitions;
34    }
35
36    public function isReadOnly() : bool
37    {
38        return $this->readOnly;
39    }
40
41    public function makeReadOnly() : void
42    {
43        $this->readOnly = true;
44    }
45
46    public function isVerifyATN() : bool
47    {
48        return $this->verifyATN;
49    }
50
51    public function setVerifyATN(bool $verifyATN) : void
52    {
53        if ($this->readOnly) {
54            throw new \InvalidArgumentException('The object is read only.');
55        }
56
57        $this->verifyATN = $verifyATN;
58    }
59
60    public function isGenerateRuleBypassTransitions() : bool
61    {
62        return $this->generateRuleBypassTransitions;
63    }
64
65    public function setGenerateRuleBypassTransitions(bool $generateRuleBypassTransitions) : void
66    {
67        if ($this->readOnly) {
68            throw new \InvalidArgumentException('The object is read only.');
69        }
70
71        $this->generateRuleBypassTransitions = $generateRuleBypassTransitions;
72    }
73}
74