Skip to content

Commit

Permalink
replace filesystem queue glob iterator with filesystem iterator + cal…
Browse files Browse the repository at this point in the history
…lback filter iterator for stream support (#65)
  • Loading branch information
frederikbosch committed Mar 13, 2020
1 parent 51bee44 commit 6fe7a98
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Queue/FilesystemQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ public function store(MessageInterface $message): void
*/
public function fetch(): MessageInterface
{
$queue = new \GlobIterator($this->directory . '/*.eml');
$queue = new \CallbackFilterIterator(
new \FilesystemIterator($this->directory),
function (\SplFileInfo $file) {
return $file->getExtension() === 'eml';
}
);

/** @var \SplFileInfo $item */
foreach ($queue as $item) {
$messageString = \file_get_contents($item->getPathname());
Expand Down

0 comments on commit 6fe7a98

Please sign in to comment.