* @link http://www.pradosoft.com/
* @copyright Copyright © 2005-2014 PradoSoft
* @license http://www.pradosoft.com/license/
* @package Prado\Collections
*/
namespace Prado\Collections;
/**
* TDummyDataSource class
*
* TDummyDataSource implements a dummy data collection with a specified number
* of dummy data items. The number of virtual items can be set via
* {@link setCount Count} property. You can traverse it using foreach
* PHP statement like the following,
*
* foreach($dummyDataSource as $dataItem)
*
*
* @author Qiang Xue
* @package Prado\Collections
* @since 3.0
*/
class TDummyDataSource extends \Prado\TComponent implements \IteratorAggregate, \Countable
{
private $_count;
/**
* Constructor.
* @param integer number of (virtual) items in the data source.
*/
public function __construct($count)
{
$this->_count=$count;
}
/**
* @return integer number of (virtual) items in the data source.
*/
public function getCount()
{
return $this->_count;
}
/**
* @return Iterator iterator
*/
public function getIterator()
{
return new TDummyDataSourceIterator($this->_count);
}
/**
* Returns the number of (virtual) items in the data source.
* This method is required by \Countable interface.
* @return integer number of (virtual) items in the data source.
*/
public function count()
{
return $this->getCount();
}
}