1 | <?php |
||
24 | class Enumerator |
||
25 | { |
||
26 | |||
27 | /** |
||
28 | * Path to the root directory, where enumeration should start |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $rootDirectory; |
||
33 | |||
34 | /** |
||
35 | * List of additional include paths, should be below rootDirectory |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | private $includePaths; |
||
40 | |||
41 | /** |
||
42 | * List of additional exclude paths, should be below rootDirectory |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | private $excludePaths; |
||
47 | 7 | ||
48 | /** |
||
49 | 7 | * Initializes an enumerator |
|
50 | 7 | * |
|
51 | 7 | * @param string $rootDirectory Path to the root directory |
|
52 | 7 | * @param array $includePaths List of additional include paths |
|
53 | * @param array $excludePaths List of additional exclude paths |
||
54 | */ |
||
55 | public function __construct($rootDirectory, array $includePaths = [], array $excludePaths = []) |
||
61 | 7 | ||
62 | 7 | /** |
|
63 | 7 | * Returns an enumerator for files |
|
64 | 7 | * |
|
65 | * @return CallbackFilterIterator|RecursiveIteratorIterator|SplFileInfo[] |
||
66 | * @throws UnexpectedValueException |
||
67 | * @throws InvalidArgumentException |
||
68 | 7 | * @throws LogicException |
|
69 | 7 | */ |
|
70 | public function enumerate() |
||
80 | |||
81 | 7 | /** |
|
82 | 7 | * @return array |
|
83 | 7 | * @throws UnexpectedValueException |
|
84 | */ |
||
85 | 7 | private function getInPaths() |
|
104 | |||
105 | 1 | /** |
|
106 | * @return array |
||
107 | */ |
||
108 | private function getExcludePaths() |
||
119 | |||
120 | /** |
||
121 | * Returns a filter callback for enumerating files |
||
122 | * |
||
123 | * @return \Closure |
||
124 | */ |
||
125 | public function getFilter() |
||
165 | |||
166 | /** |
||
167 | * Return the real path of the given file |
||
168 | * |
||
169 | * This is used for testing purpose with virtual file system. |
||
170 | * In a vfs the 'realPath' methode will always return false. |
||
171 | * So we have a chance to mock this single function to return different path. |
||
172 | * |
||
173 | * @param SplFileInfo $file |
||
174 | * |
||
175 | * @return string |
||
176 | */ |
||
177 | protected function getFileFullPath(SplFileInfo $file) |
||
181 | |||
182 | } |
||
183 |