/** * @inheritdoc */ public function get($key) { if (!$this->containsKey($key)) { throw OutOfRangeException::keyOutOfRange($key); } return $this->items[$key]; }
/** * @test */ public function it_creates_a_keyOutOfRange_exception() { $exception = OutOfRangeException::keyOutOfRange(0); $this->assertInstanceOf(OutOfRangeException::class, $exception); $this->assertSame('Collection does not contain the key 0', $exception->getMessage()); }