src/includes/classes/Core/Utils/Iterators.php
public function dirRecursiveRegex(string $dir, string $regex = '/.+/u'): \RegexIterator
    {
        if (!$dir || !$regex) {
            throw $this->c::issue('Missing required `$dir` and/or `$regex` parameters.');
        }
        $DirIterator      = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_SELF | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS);
        $IteratorIterator = new \RecursiveIteratorIterator($DirIterator, \RecursiveIteratorIterator::CHILD_FIRST);
        $RegexIterator    = new \RegexIterator($IteratorIterator, $regex, \RegexIterator::MATCH, \RegexIterator::USE_KEY);

        return $RegexIterator;
    }
public function dirRecursiveRegex(string $dir, string $regex = '/.+/u'): \RegexIterator
    {
        if (!$dir || !$regex) {
            throw $this->c::issue('Missing required `$dir` and/or `$regex` parameters.');
        }
        $DirIterator      = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_SELF | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS);
        $IteratorIterator = new \RecursiveIteratorIterator($DirIterator, \RecursiveIteratorIterator::CHILD_FIRST);
        $RegexIterator    = new \RegexIterator($IteratorIterator, $regex, \RegexIterator::MATCH, \RegexIterator::USE_KEY);

        return $RegexIterator;
    }
Recursive dir/regex iterator.

@since 150424 Initial release.

@param string $dir   Directory to scan.
@param string $regex Regular expression.

@throws Exception If either of the input parameters are empty.

@return \RegexIterator Recursive dir/regex iterator.