1 | <?php |
||
25 | class Enumerator |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Path to the root directory, where enumeration should start |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $rootDirectory; |
||
34 | |||
35 | /** |
||
36 | * List of additional include paths, should be below rootDirectory |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $includePaths; |
||
41 | |||
42 | /** |
||
43 | * List of additional exclude paths, should be below rootDirectory |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | private $excludePaths; |
||
48 | |||
49 | /** |
||
50 | * Initializes an enumerator |
||
51 | * |
||
52 | * @param string $rootDirectory Path to the root directory |
||
53 | * @param array $includePaths List of additional include paths |
||
54 | * @param array $excludePaths List of additional exclude paths |
||
55 | */ |
||
56 | 7 | public function __construct($rootDirectory, array $includePaths = [], array $excludePaths = []) |
|
62 | |||
63 | /** |
||
64 | * Returns an enumerator for files |
||
65 | * |
||
66 | * @return \Iterator|SplFileInfo[] |
||
67 | * @throws UnexpectedValueException |
||
68 | * @throws InvalidArgumentException |
||
69 | * @throws LogicException |
||
70 | */ |
||
71 | 7 | public function enumerate() |
|
91 | |||
92 | /** |
||
93 | * @return array |
||
94 | * @throws UnexpectedValueException |
||
95 | */ |
||
96 | 7 | private function getInPaths() |
|
115 | |||
116 | /** |
||
117 | * @return array |
||
118 | */ |
||
119 | 7 | private function getExcludePaths() |
|
130 | |||
131 | /** |
||
132 | * Returns a filter callback for enumerating files |
||
133 | * |
||
134 | * @return \Closure |
||
135 | */ |
||
136 | public function getFilter() |
||
176 | |||
177 | /** |
||
178 | * Return the real path of the given file |
||
179 | * |
||
180 | * This is used for testing purpose with virtual file system. |
||
181 | * In a vfs the 'realPath' methode will always return false. |
||
182 | * So we have a chance to mock this single function to return different path. |
||
183 | * |
||
184 | * @param SplFileInfo $file |
||
185 | * |
||
186 | * @return string |
||
187 | */ |
||
188 | protected function getFileFullPath(SplFileInfo $file) |
||
192 | |||
193 | } |
||
194 |