/** * Get instance of DirectoryScanner with filter options applied * * @param bool $filter * @return DirectoryScanner */ public function getScanner($filter = TRUE) { $scanner = new DirectoryScanner(); if ($filter) { $scanner->setIncludes($this->config->getInclude()); $scanner->setExcludes($this->config->getExclude()); } if ($this->config->isFollowSymlinks()) { $scanner->setFlag(\FilesystemIterator::FOLLOW_SYMLINKS); } return $scanner; }
/** * Find all files matching *.txt and not being in 'nested' folder */ public function testRecursiveFindByIncludeAndExclude() { $tmp = new DirectoryScanner(); $tmp->addInclude('*.txt'); $tmp->addExclude('*/nested/*'); $x = $tmp->getFiles(__DIR__ . '/_data'); $this->assertEquals(1, count($x)); }