Total Complexity | 16 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
7 | class RecursiveFileListing { |
||
8 | |||
9 | private $root_dir; |
||
10 | private $files; |
||
11 | private $filters = []; |
||
12 | |||
13 | public function __construct (string $dir) { |
||
14 | if (!is_dir($dir)) { |
||
15 | throw new Exception("Directory required"); |
||
16 | } |
||
17 | |||
18 | $this->root_dir = $dir; |
||
19 | } |
||
20 | |||
21 | public function addFilter (string $regex) { |
||
22 | $this->filters[] = $regex; |
||
23 | } |
||
24 | |||
25 | public function clearFilters () { |
||
26 | $this->filters = []; |
||
27 | } |
||
28 | |||
29 | public function scan () : array { |
||
34 | } |
||
35 | |||
36 | private function recursiveScan (string $dir) { |
||
37 | $files = scandir($dir); |
||
38 | foreach ($files as $filename) { |
||
39 | if ($filename !== "." && $filename !== "..") { |
||
40 | $file_path = $dir . "/" . $filename; |
||
41 | if (is_file($file_path) && $this->isFileOk($file_path)) { |
||
42 | $this->files[] = $file_path; |
||
43 | } else if (is_dir($file_path)) { |
||
44 | $this->recursiveScan($file_path); |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 | |||
50 | private function isFileOk (string $path) : bool { |
||
62 | } |
||
63 | |||
64 | } |