/** * Filter files in the collection by expression and return new file collection. * * @param string[] $paths * * @return FileCollection */ public function filter(array $paths) { $filteredFiles = array(); foreach ($this->files as $file) { if (PathUtils::matches($file->getName(), $paths)) { $filteredFiles[] = $file; } } return new FileCollection($filteredFiles); }
/** * @dataProvider getFilteringTests */ public function testIsFiltered($path, array $includedPaths, array $excludedPaths, $expectedOutcome) { $this->assertSame($expectedOutcome, PathUtils::isFiltered($path, array('paths' => $includedPaths, 'excluded_paths' => $excludedPaths))); }