SymbolListShortcut   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 16
dl 0
loc 50
rs 10
c 2
b 0
f 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetGet() 0 7 1
A offsetSet() 0 4 1
A offsetExists() 0 6 1
A offsetUnset() 0 4 1
A __construct() 0 3 1
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