1 | <?php |
||
26 | class Enumerator |
||
27 | { |
||
28 | /** |
||
29 | * Path to the root directory, where enumeration should start |
||
30 | */ |
||
31 | private $rootDirectory; |
||
32 | |||
33 | /** |
||
34 | * List of additional include paths, should be below rootDirectory |
||
35 | */ |
||
36 | private $includePaths; |
||
37 | |||
38 | /** |
||
39 | * List of additional exclude paths, should be below rootDirectory |
||
40 | */ |
||
41 | private $excludePaths; |
||
42 | |||
43 | /** |
||
44 | * Initializes an enumerator |
||
45 | * |
||
46 | * @param string $rootDirectory Path to the root directory |
||
47 | * @param array $includePaths List of additional include paths |
||
48 | * @param array $excludePaths List of additional exclude paths |
||
49 | */ |
||
50 | 8 | public function __construct(string $rootDirectory, array $includePaths = [], array $excludePaths = []) |
|
56 | |||
57 | /** |
||
58 | * Returns an enumerator for files |
||
59 | * |
||
60 | * @return Iterator|SplFileInfo[] |
||
61 | * @throws UnexpectedValueException |
||
62 | * @throws InvalidArgumentException |
||
63 | * @throws LogicException |
||
64 | */ |
||
65 | 7 | public function enumerate(): Iterator |
|
85 | |||
86 | /** |
||
87 | * Returns a filter callback for enumerating files |
||
88 | */ |
||
89 | 18 | public function getFilter(): Closure |
|
129 | |||
130 | /** |
||
131 | * Return the real path of the given file |
||
132 | * |
||
133 | * This is used for testing purpose with virtual file system. |
||
134 | * In a vfs the 'realPath' methode will always return false. |
||
135 | * So we have a chance to mock this single function to return different path. |
||
136 | */ |
||
137 | 18 | protected function getFileFullPath(SplFileInfo $file): string |
|
141 | |||
142 | /** |
||
143 | * Returns collection of directories to look at |
||
144 | * |
||
145 | * @throws UnexpectedValueException if directory not under the root |
||
146 | */ |
||
147 | 7 | private function getInPaths(): array |
|
166 | |||
167 | /** |
||
168 | * Returns the list of excluded paths |
||
169 | */ |
||
170 | 7 | private function getExcludePaths(): array |
|
181 | } |
||
182 |