Implement ArrayAccess interface for Vector and HashMap
[keruald.git] / src / Collections / BaseMap.php
blobd0d4df507df56e092e7fa201413b84daeeab2846
1 <?php
3 namespace Keruald\OmniTools\Collections;
5 use ArrayAccess;
7 abstract class BaseMap extends BaseCollection implements ArrayAccess {
9 ///
10 /// Methods to implement
11 ///
13 public abstract function get (mixed $key) : mixed;
15 public abstract function getOr (mixed $key, mixed $defaultValue): mixed;
17 public abstract function set (mixed $key, mixed $value) : static;
19 public abstract function unset (mixed $key) : static;
21 public abstract function has (mixed $key) : bool;
23 public abstract function contains (mixed $value) : bool;
25 ///
26 /// ArrayAccess
27 /// Interface to provide accessing objects as arrays.
28 ///
30 public function offsetExists (mixed $offset) : bool {
31 return $this->has($offset);
34 public function offsetGet (mixed $offset) : mixed {
35 return $this->get($offset);
38 public function offsetSet (mixed $offset, mixed $value) : void {
39 $this->set($offset, $value);
42 public function offsetUnset (mixed $offset) : void {
43 $this->unset($offset);