AttributeListShortcut::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\AttributeListInterface;
9
use Remorhaz\UniLex\Exception;
10
use ReturnTypeWillChange;
11
12
class AttributeListShortcut implements ArrayAccess
13
{
14
    private $attributeList;
15
16
    public function __construct(AttributeListInterface $attributeList)
17
    {
18
        $this->attributeList = $attributeList;
19
    }
20
21
    /**
22
     * @param mixed $offset
23
     * @return mixed
24
     */
25
    #[ReturnTypeWillChange]
26
    public function offsetGet($offset)
27
    {
28
        return $this
29
            ->attributeList
30
            ->getAttribute($offset);
31
    }
32
33
    /**
34
     * @param mixed $offset
35
     * @param mixed $value
36
     */
37
    #[ReturnTypeWillChange]
38
    public function offsetSet($offset, $value)
39
    {
40
        $this
41
            ->attributeList
42
            ->setAttribute($offset, $value);
43
    }
44
45
    /**
46
     * @param mixed $offset
47
     * @return bool
48
     */
49
    #[ReturnTypeWillChange]
50
    public function offsetExists($offset)
51
    {
52
        return $this
53
            ->attributeList
54
            ->attributeExists($offset);
55
    }
56
57
    /**
58
     * @param mixed $offset
59
     * @throws Exception
60
     */
61
    #[ReturnTypeWillChange]
62
    public function offsetUnset($offset)
63
    {
64
        throw new Exception("Cannot remove symbol attribute");
65
    }
66
}
67