data = $data; } public function offsetExists($offset){ $this->fire('exists', $offset); return isset($this->data[$offset]); } public function offsetGet($offset){ $this->fire('get', $offset); return $this->data[$offset]; } public function offsetSet($offset, $value){ $this->fire('set', $offset, $value); $this->data[$offset] = $value; } public function offsetUnset($offset){ if($this->offsetExists($offset)){ $this->fire('unset', $offset, $this[$offset]); unset($this->data[$offset]); } } public function count(){ return count($this->data); } public function each(callable $fn){ foreach($this->data as $offset => $model){ $fn($model, $offset); } return $this; } public function to_array(){ return $this->data; } } ?>