Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
14 | 3 | public function findFiles(string $path, ?array $validExtensions = null): array |
|
15 | { |
||
16 | 3 | $files = (new Finder())->files() |
|
17 | 3 | ->in($path) |
|
18 | 3 | ->ignoreUnreadableDirs(); |
|
19 | |||
20 | 3 | if ($validExtensions !== null && count($validExtensions) > 0) { |
|
21 | 3 | $files->name(sprintf( |
|
22 | 3 | '/\.(%s)$/', |
|
23 | 3 | implode('|', $validExtensions) |
|
24 | )); |
||
25 | } |
||
26 | |||
27 | 3 | $videos = []; |
|
28 | |||
29 | /** @var \SplFileInfo $file */ |
||
30 | 3 | foreach ($files as $file) { |
|
31 | 3 | $videos[] = $file; |
|
32 | } |
||
33 | |||
34 | 3 | return $videos; |
|
35 | } |
||
37 |