Changeset 912 -- 2009-06-03 22:53:07
- Author
hnw
- Comment
- Only Traversable class can be wrapped. If not, throws exception.
Diffs
IgnoreExceptionIterator/trunk/src/IgnoreExceptionIterator.php
@@ -15,9 +15,16 @@
protected $it;
protected $already_caught_exception = false;
- public function __construct($it)
+ public function __construct(Traversable $it)
{
- $this->it = $it;
+ if ($it instanceof IteratorAggregate) {
+ $it = $iterator->getIterator();
+ }
+ if ($it instanceof Iterator) {
+ $this->it = $it;
+ } else {
+ throw new Exception("Only Traversable class can be wrapped by IgnoreExceptionIterator.");
+ }
}
public function getInnerIterator()
{