private function iteratorToCollection(Iterator $iterator)
{
$filesystemPaths = iterator_to_array($iterator);
$resources = array();
// RecursiveDirectoryIterator is not guaranteed to return sorted results
sort($filesystemPaths);
foreach ($filesystemPaths as $filesystemPath) {
$resource = is_dir($filesystemPath) ? new DirectoryResource($filesystemPath, $this->getPath($filesystemPath)) : new FileResource($filesystemPath, $this->getPath($filesystemPath));
$resource->attachTo($this);
$resources[] = $resource;
}
return new FilesystemResourceCollection($resources);
}