Example #1
0
 /**
  * @inheritdoc
  */
 public function add($key, Equatable $value)
 {
     if ($this->containsKey($key)) {
         throw InRangeException::keyInRange($key);
     }
     $items = $this->items;
     $items[$key] = $value;
     return new static($items);
 }
Example #2
0
 /**
  * @test
  */
 public function it_creates_a_keyInRange_exception()
 {
     $exception = InRangeException::keyInRange(0);
     $this->assertInstanceOf(InRangeException::class, $exception);
     $this->assertSame('Collection already contains the key 0', $exception->getMessage());
 }