* @category TQ * @package TQ_Git * @subpackage StreamWrapper * @copyright Copyright (C) 2011 by TEQneers GmbH & Co. KG */ class DirectoryBuffer implements \Iterator { /** * The directory listing * * @var array */ protected $listing; /** * Creates a directory buffer from an array * * @param array $listing The directory listing */ public function __construct(array $listing) { $this->listing = $listing; reset($this->listing); } /** * Implements Iterator * * @link http://php.net/manual/en/iterator.current.php * @return string */ public function current() { return current($this->listing); } /** * Implements Iterator * * @link http://php.net/manual/en/iterator.next.php */ public function next() { next($this->listing); } /** * Implements Iterator * * @link http://php.net/manual/en/iterator.key.php * @return integer|boolean False on failure */ public function key() { return key($this->listing); } /** * Implements Iterator * * @link http://php.net/manual/en/iterator.valid.php * @return boolean */ public function valid() { return (key($this->listing) !== null); } /** * Implements Iterator * * @link http://php.net/manual/en/iterator.rewind.php */ public function rewind() { reset($this->listing); } }