slogsdon/php-flat-file

View on GitHub
src/Files.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php declare(strict_types=1);

namespace FlatFile;

class Files
{
    public function findAll(string $root): iterable
    {
        $dir = new \RecursiveDirectoryIterator($root);
        $ite = new \RecursiveIteratorIterator($dir);
        $fileIterator = new \RegexIterator($ite, '/[^\/]*/');
        foreach ($fileIterator as $file) {
            if ($file->getFileName() === '.' || $file->getFileName() === '..') {
                continue;
            }
            yield $file;
        }
    }
}