Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
22 | 5 | public static function recursiveSearchByExtension($path, $extension, Array $excludes = null) |
|
23 | { |
||
24 | 5 | $files = array(); |
|
25 | 5 | if (!is_dir($path)) { |
|
26 | 1 | throw new \Exception('Path given is not an existant directory.'); |
|
27 | } |
||
28 | |||
29 | 4 | $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS); |
|
30 | 4 | $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::LEAVES_ONLY); |
|
31 | |||
32 | 4 | foreach ($iterator as $fileinfo) { |
|
33 | 4 | if ($fileinfo->getExtension() == $extension && !Regex::matchesAny($fileinfo->getPathname(),$excludes)) { |
|
34 | 4 | $files[] = realpath($fileinfo->getPathname()); |
|
35 | 4 | } |
|
36 | 4 | } |
|
37 | 4 | return $files; |
|
38 | } |
||
39 | |||
54 |