@@ -30,6 +30,16 @@ class LintCommand extends Command
30
30
private $ parser ;
31
31
private $ format ;
32
32
private $ displayCorrectFiles ;
33
+ private $ directoryIteratorProvider ;
34
+ private $ isReadableProvider ;
35
+
36
+ public function __construct ($ name = null , $ directoryIteratorProvider = null , $ isReadableProvider = null )
37
+ {
38
+ parent ::__construct ($ name );
39
+
40
+ $ this ->directoryIteratorProvider = $ directoryIteratorProvider ;
41
+ $ this ->isReadableProvider = $ isReadableProvider ;
42
+ }
33
43
34
44
/**
35
45
* {@inheritdoc}
@@ -170,14 +180,6 @@ private function getFiles($fileOrDirectory)
170
180
}
171
181
}
172
182
173
- protected function getDirectoryIterator ($ directory )
174
- {
175
- return new \RecursiveIteratorIterator (
176
- new \RecursiveDirectoryIterator ($ directory , \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS ),
177
- \RecursiveIteratorIterator::LEAVES_ONLY
178
- );
179
- }
180
-
181
183
private function getStdin ()
182
184
{
183
185
if (0 !== ftell (STDIN )) {
@@ -201,8 +203,32 @@ private function getParser()
201
203
return $ this ->parser ;
202
204
}
203
205
204
- protected function isReadable ( $ fileOrDirectory )
206
+ private function getDirectoryIterator ( $ directory )
205
207
{
206
- return is_readable ($ fileOrDirectory );
208
+ $ default = function ($ directory ) {
209
+ return new \RecursiveIteratorIterator (
210
+ new \RecursiveDirectoryIterator ($ directory , \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS ),
211
+ \RecursiveIteratorIterator::LEAVES_ONLY
212
+ );
213
+ };
214
+
215
+ if (null !== $ this ->directoryIteratorProvider ) {
216
+ return call_user_func ($ this ->directoryIteratorProvider , $ directory , $ default );
217
+ }
218
+
219
+ return $ default ($ directory );
220
+ }
221
+
222
+ private function isReadable ($ fileOrDirectory )
223
+ {
224
+ $ default = function ($ fileOrDirectory ) {
225
+ return is_readable ($ fileOrDirectory );
226
+ };
227
+
228
+ if (null !== $ this ->isReadableProvider ) {
229
+ return call_user_func ($ this ->isReadableProvider , $ fileOrDirectory , $ default );
230
+ }
231
+
232
+ return $ default ($ fileOrDirectory );
207
233
}
208
234
}
0 commit comments