What is the correct class name for recursively iterating through directories in PHP?

To recursively iterate through directories in PHP, you can create a class that uses recursion to traverse each directory and its subdirectories. The class should use the DirectoryIterator class to loop through the contents of each directory and check if each item is a file or a directory. If a directory is found, the class should call itself recursively to continue iterating through its contents. This approach allows you to effectively traverse nested directories and perform actions on the files within them.

class DirectoryIteratorRecursive {
    public function iterateDirectory($dir) {
        $iterator = new DirectoryIterator($dir);
        
        foreach ($iterator as $item) {
            if ($item->isDir() && !$item->isDot()) {
                $this->iterateDirectory($item->getPathname());
            } else {
                echo $item->getPathname() . PHP_EOL;
            }
        }
    }
}

// Usage example
$dirIterator = new DirectoryIteratorRecursive();
$dirIterator->iterateDirectory('/path/to/directory');