. */ require_once('CFDBWpdbResultIterator.php'); require_once('CFDBWpdbUnbufferedResultIterator.php'); /** * @singleton */ class CFDBQueryResultIteratorFactory { /** * @var CFDBAbstractQueryResultsIterator mock instance */ var $mock; public static function getInstance() { static $inst = null; if ($inst === null) { $inst = new CFDBQueryResultIteratorFactory(); } return $inst; } /** * @param $mock CFDBAbstractQueryResultsIterator mock for CFDBQueryResultIterator */ public function setQueryResultsIteratorMock($mock) { $this->mock = $mock; } public function clearMock() { $this->mock = null; } /** * Factory method for getting a new CFDBQueryResultIterator or mock. * @param $unbuffered bool * @return CFDBAbstractQueryResultsIterator (or mock) */ public function newQueryIterator($unbuffered = false) { if ($this->mock) { return $this->mock; } if ($unbuffered) { return new CFDBWpdbUnbufferedResultIterator; } else { return new CFDBWpdbResultIterator; } } }