@@ 52-63 (lines=12) @@ | ||
49 | $this->items = $items; |
|
50 | } |
|
51 | ||
52 | public function add(string $key, Equatable $value): EquatableMap |
|
53 | { |
|
54 | if ($this->containsKey($key)) { |
|
55 | throw InRangeException::keyInRange($key); |
|
56 | } |
|
57 | ||
58 | $items = $this->items; |
|
59 | ||
60 | $items[$key] = $value; |
|
61 | ||
62 | return new static($items); |
|
63 | } |
|
64 | ||
65 | public function remove(Equatable $value): EquatableMap |
|
66 | { |
|
@@ 75-86 (lines=12) @@ | ||
72 | return new static($items); |
|
73 | } |
|
74 | ||
75 | public function replace(string $key, Equatable $value): EquatableMap |
|
76 | { |
|
77 | if (!$this->containsKey($key)) { |
|
78 | throw OutOfRangeException::keyOutOfRange($key); |
|
79 | } |
|
80 | ||
81 | $items = $this->items; |
|
82 | ||
83 | $items[$key] = $value; |
|
84 | ||
85 | return new static($items); |
|
86 | } |
|
87 | ||
88 | public function get(string $key): Equatable |
|
89 | { |