Actually, I was thinking if would make sense to use https://github.com/symfony/Finder (it's already a dependency).