Esempio n. 1
0
 public function __construct(\Iterator $iterator, $callback)
 {
     parent::__construct($iterator);
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('The callback must be callable');
     }
     $this->callback = $callback;
 }
 /**
  * Wraps a generated iterator in a filter iterator that removes directories
  *
  * @param \Iterator $iterator Iterator to wrap
  *
  * @return \Iterator
  * @throws UnexpectedValueException
  */
 protected function filterIterator(\Iterator $iterator)
 {
     $f = new FilterIterator($iterator, function ($i) {
         if (!$i instanceof \SplFileInfo) {
             throw new UnexpectedValueException('All iterators for UploadSync must return SplFileInfo objects');
         }
         return $i->isFile();
     });
     $f->rewind();
     return $f;
 }