/** * Examine each file and directory beneath the path, and return an SplFileInfo * object for each one. The depth will be limited to $depth levels, if provided. * * The options array may be used to limit the depth of the recursion: * * depth = -1 is the default, and sets no limit on the recursion. * depth = 0 will return no results * depth = 1 will return results for the top level directory. * depth = 2 will return results for the top two directories. * etc. * * The options may also be used to exclude directories * * exclude = array('foo', 'bar') will prevent the finder * from looking in directories called foo or bar. * * @param Closure $callback * @param array $options * @return SplFileInfo[] */ public function find(Closure $callback = null, $options = array()) { if ($callback === null) { $callback = function (SplFileInfo $fileInfo) { return true; }; } if (!array_key_exists('depth', $options)) { $options['depth'] = -1; } if (!array_key_exists('exclude', $options)) { $options['exclude'] = array(); } $iterator = $this->adapter->getRoot(); $matches = $this->recurse($callback, $iterator, $options); return $matches; }