How to access the first file of a Finder::files() result?
$iterator = $finder->getIterator();
$iterator->rewind();
$firstFile = $iterator->current();
Try to rewind
first or \var_dump(\iterator_to_array($finder));
.
The sequence of an iterator is:
- rewind
- valid
- current/key
- next
- valid
- current/key
- next
- ...