user = new \Core\User(); $this->ids = $this->user->getIds(); } /** * 第三步:拿到当前数据 * @return mixed|void */ public function current() { // TODO: Implement current() method. $id = $this->ids[$this->index]['id']; return $this->user->getUserById($id); } /** * 迭代器索引增幅 */ public function next() { // TODO: Implement next() method. $this->index ++; } /** * @return bool|迭代器的当前位置|float|int|string|null */ public function key() { // TODO: Implement key() method. return $this->index; } /** * 第一步:将索引标记在开头 */ public function rewind() { // TODO: Implement rewind() method. $this->index = 0; } /** * 第二步:验证是否还有下一个元素 * @return bool|void */ public function valid() { // TODO: Implement valid() method. return $this->index < count($this->ids); } }