| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Builds shape based on shape references. |
| 7 | 7 | */ |
| 8 | -class ShapeMap | |
| 8 | +class ShapeMap implements \ArrayAccess | |
| 9 | 9 | { |
| 10 | 10 | /** @var array */ |
| 11 | 11 | private $definitions; |
| 12 | 12 | /** @var Shape[] */ |
| @@ -54,6 +54,39 @@ | ||
| 54 | 54 | if ($isSimple) { |
| 55 | 55 | $this->simple[$shape] = $result; |
| 56 | 56 | } |
| 57 | 57 | return $result; |
| 58 | + } | |
| 59 | + /** | |
| 60 | + * @param mixed $offset | |
| 61 | + * @return bool | |
| 62 | + */ | |
| 63 | + public function offsetExists(mixed $offset) : bool | |
| 64 | + { | |
| 65 | + return isset($this->definitions[$offset]); | |
| 66 | + } | |
| 67 | + /** | |
| 68 | + * @param mixed $offset | |
| 69 | + * @return mixed | |
| 70 | + */ | |
| 71 | + public function offsetGet(mixed $offset) : mixed | |
| 72 | + { | |
| 73 | + return $this->definitions[$offset] ?? null; | |
| 74 | + } | |
| 75 | + /** | |
| 76 | + * @param mixed $offset | |
| 77 | + * @param mixed $value | |
| 78 | + * @throws \BadMethodCallException | |
| 79 | + */ | |
| 80 | + public function offsetSet(mixed $offset, mixed $value) : void | |
| 81 | + { | |
| 82 | + throw new \BadMethodCallException('ShapeMap is read-only and cannot be modified.'); | |
| 83 | + } | |
| 84 | + /** | |
| 85 | + * @param mixed $offset | |
| 86 | + * @throws \BadMethodCallException | |
| 87 | + */ | |
| 88 | + public function offsetUnset(mixed $offset) : void | |
| 89 | + { | |
| 90 | + throw new \BadMethodCallException('ShapeMap is read-only and cannot be modified.'); | |
| 58 | 91 | } |
| 59 | 92 | } |