/** * 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 getMatchingTests */ public function testMatches($path, array $patterns, $expectedOutcome) { $this->assertSame($expectedOutcome, PathUtils::matches($path, $patterns)); }