Conditions | 2 |
Paths | 2 |
Total Lines | 34 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function getFilesystemInput(string $cwd, array $paths, array $extensions, array $ignore): iterable |
||
23 | { |
||
24 | $finder = (new Finder())->files()->in($cwd)->ignoreUnreadableDirs(); |
||
25 | |||
26 | // Set paths to scan |
||
27 | |||
28 | $finder->path( |
||
29 | array_map( |
||
30 | fn($path) => '/^' . preg_quote($path, '/') . '/i', |
||
31 | $paths |
||
32 | ) |
||
33 | ); |
||
34 | |||
35 | // Set file extensions |
||
36 | |||
37 | $finder->name( |
||
38 | array_map( |
||
39 | fn($extension) => '/\\.' . preg_quote($extension, '/') . '$/i', |
||
40 | $extensions |
||
41 | ) |
||
42 | ); |
||
43 | |||
44 | // Set paths to ignore |
||
45 | |||
46 | $finder->notPath( |
||
47 | array_map( |
||
48 | fn($path) => '/^' . preg_quote($path, '/') . '/i', |
||
49 | $ignore |
||
50 | ) |
||
51 | ); |
||
52 | |||
53 | foreach ($finder as $file) { |
||
54 | yield new Compiler\FileInput($file); |
||
55 | $this->dispatcher->dispatch(new Event\FileIncluded($file)); |
||
56 | } |
||
59 |