GlobIterator: Easy access to specific files
GlobIterator exists since PHP5.3, and basically allows to iterator over anything glob()able. So instead of having to write my own custom FilterIterator and pass the DirectoryIterator for my directory to that FilterIterator, I can simple instantiate GlobIterator and pass the pattern that I need to it:
$watchDir = new \GlobIterator($config['incomingPath'].'/*.xml');
Now I can foreach over $watchDir and do whatever I need to do (in this case parse XML) with only a couple of lines of code! WIN!
Update: Davey rightfully asked “why not use glob() in the first place?”. To clarify: I am using GlobIterator because I want to have SplFileInfo objects instead of just plain filenames. I need some of the meta info SplFileInfo offers.