<?php
namespace App\EntityList; class RecordIterator implements \Iterator { private $recordSet = null; private $position = 0; private $entity = ""; public function __construct( $recordSet, $entity ) { $this->recordSet = $recordSet; $this->position = 0; $this->entity = $entity; } public function rewind() :void { $this->position = 0; } public function current() :mixed { $ret = $this->recordSet->fields; $ret['entity'] = call_user_func([$this->entity, "select"], $this->recordSet->fields['id']); return $ret; } public function key() :mixed { return $this->position; } public function next() :void { $this->position++; $this->recordSet->MoveNext(); } public function valid() :bool { return !$this->recordSet->EOF; } } 