SymbolListShortcut::offsetExists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\UniLex\Parser;
6
7
use ArrayAccess;
8
use Remorhaz\UniLex\Exception;
9
use ReturnTypeWillChange;
10
11
class SymbolListShortcut implements ArrayAccess
12
{
13
    private $production;
14
15
    public function __construct(Production $production)
16
    {
17
        $this->production = $production;
18
    }
19
20
    /**
21
     * @param mixed $offset
22
     * @return mixed|array|AttributeListShortcut
23
     * @throws Exception
24
     */
25
    #[ReturnTypeWillChange]
26
    public function offsetGet($offset)
27
    {
28
        $symbol = $this
29
            ->production
30
            ->getSymbol($offset);
31
        return new AttributeListShortcut($symbol);
32
    }
33
34
    /**
35
     * @param mixed $offset
36
     * @param mixed $value
37
     * @throws Exception
38
     */
39
    #[ReturnTypeWillChange]
40
    public function offsetSet($offset, $value)
41
    {
42
        throw new Exception("Cannot change production symbol");
43
    }
44
45
    /**
46
     * @param mixed $offset
47
     * @throws Exception
48
     */
49
    #[ReturnTypeWillChange]
50
    public function offsetUnset($offset)
51
    {
52
        throw new Exception("Cannot remove production symbol");
53
    }
54
55
    #[ReturnTypeWillChange]
56
    public function offsetExists($offset)
57
    {
58
        return $this
59
            ->production
60
            ->symbolExists($offset);
61
    }
62
}
63