コード例 #1
0
ファイル: Finder.php プロジェクト: shulard/File
 /**
  * Get the iterator.
  *
  * @return  \Traversable
  */
 public function getIterator()
 {
     $_iterator = new Iterator\Append();
     $types = $this->getTypes();
     if (!empty($types)) {
         $this->_filters[] = function (\SplFileInfo $current) use($types) {
             return in_array($current->getType(), $types);
         };
     }
     $maxDepth = $this->getMaxDepth();
     $splFileInfo = $this->getSplFileInfo();
     foreach ($this->getPaths() as $path) {
         if (1 == $maxDepth) {
             $iterator = new Iterator\IteratorIterator(new Iterator\Recursive\Directory($path, $this->getFlags(), $splFileInfo), $this->getFirst());
         } else {
             $iterator = new Iterator\Recursive\Iterator(new Iterator\Recursive\Directory($path, $this->getFlags(), $splFileInfo), $this->getFirst());
             if (1 < $maxDepth) {
                 $iterator->setMaxDepth($maxDepth - 1);
             }
         }
         $_iterator->append($iterator);
     }
     foreach ($this->getFilters() as $filter) {
         $_iterator = new Iterator\CallbackFilter($_iterator, $filter);
     }
     $sorts = $this->getSorts();
     if (empty($sorts)) {
         return $_iterator;
     }
     $array = iterator_to_array($_iterator);
     foreach ($sorts as $sort) {
         uasort($array, $sort);
     }
     return new Iterator\Map($array);
 }
コード例 #2
0
ファイル: Append.php プロジェクト: Grummfy/Central
 public function case_singleton()
 {
     $this->given($counter1 = new LUT\Counter(0, 12, 3), $append = new LUT\Append(), $append->append($counter1))->when($result = iterator_to_array($append))->then->array($result)->isEqualTo([0, 3, 6, 9]);
 }