Conditions | 6 |
Paths | 5 |
Total Lines | 24 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public function getFilesFromPath($path) |
||
15 | { |
||
16 | if (\false === \is_dir($path) && \false === \is_file($path)) { |
||
17 | throw new InvalidArgumentException("Provided input is not a file nor a valid directory"); |
||
18 | } |
||
19 | |||
20 | $files = []; |
||
21 | |||
22 | $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); |
||
23 | |||
24 | /** @var \SplFileInfo $filename */ |
||
25 | foreach ($iterator as $filename) { |
||
26 | // filter out "." and ".." |
||
27 | if ($filename->isDir()) { |
||
28 | continue; |
||
29 | } |
||
30 | |||
31 | if ("php" === \strtolower($filename->getExtension())) { |
||
32 | $files[] = $filename->getRealPath(); |
||
33 | } |
||
34 | } |
||
35 | |||
36 | return $files; |
||
37 | } |
||
38 | } |
||
39 |