public function test_offset() { $arc = new ArrayCollection(array('aap', 'aap', 'noot', 'mies')); $this->assertTrue($arc->offsetExists(0)); $this->assertTrue($arc->offsetExists(1)); $this->assertFalse($arc->offsetExists(4)); $this->assertEquals($arc->offsetGet(0), 'aap'); $this->assertEquals($arc->offsetGet(2), 'noot'); $arc->offsetSet(2, 'zus'); $this->assertEquals($arc->offsetGet(2), 'zus'); $arc->offsetUnset(0); $this->assertFalse($arc->offsetExists(0)); $this->assertTrue($arc->offsetExists(1)); }
/** * @param int $index * @return Model */ public function offsetGet($index) { $model = parent::offsetGet($index); if (!is_object($model)) { $model_class = $this->model_class; $model = $model_class::find($model); self::offsetSet($index, $model); } return $model; }
/** * @param mixed $offset * * @return CustomFieldChoice|null */ public function offsetGet($offset) { return parent::offsetGet($offset); }
/** {@inheritDoc} */ public function offsetGet($offset) { $this->initialize(); return $this->collection->offsetGet($offset); }