public static function createIterator($path, $recursive = false, $options = null)
    {
        $path = Path::clean($path);

        if ($recursive) {
            $options = $options ?: (\FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO);
        } else {
            $options = $options ?: (\FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO
                | \FilesystemIterator::SKIP_DOTS);
        }

        try {
            $iterator = new RecursiveDirectoryIterator($path, $options);
        } catch (\UnexpectedValueException $exception) {
            throw new \InvalidArgumentException(sprintf('Dir: %s not found.', (string) $path), null, $exception);
        }

        // If rescurive set to true, use RecursiveIteratorIterator
        return $recursive ? new \RecursiveIteratorIterator($iterator) : $iterator;
    }
public static function createIterator($path, $recursive = false, $options = null)
    {
        $path = Path::clean($path);

        if ($recursive) {
            $options = $options ?: (\FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO);
        } else {
            $options = $options ?: (\FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO
                | \FilesystemIterator::SKIP_DOTS);
        }

        try {
            $iterator = new RecursiveDirectoryIterator($path, $options);
        } catch (\UnexpectedValueException $exception) {
            throw new \InvalidArgumentException(sprintf('Dir: %s not found.', (string) $path), null, $exception);
        }

        // If rescurive set to true, use RecursiveIteratorIterator
        return $recursive ? new \RecursiveIteratorIterator($iterator) : $iterator;
    }
public static function createIterator ( $ path , $ recursive = false , $ options = null ) { $ path = Path :: clean ( $ path ) ; if ( $ recursive ) { $ options = $ options ? : ( \ FilesystemIterator :: KEY_AS_PATHNAME | \ FilesystemIterator :: CURRENT_AS_FILEINFO ) ; } else { $ options = $ options ? : ( \ FilesystemIterator :: KEY_AS_PATHNAME | \ FilesystemIterator :: CURRENT_AS_FILEINFO | \ FilesystemIterator :: SKIP_DOTS ) ; } try { $ iterator = new RecursiveDirectoryIterator ( $ path , $ options ) ; } catch ( \ UnexpectedValueException $ exception ) { throw new \ InvalidArgumentException ( sprintf ( 'Dir: %s not found.' , ( string ) $ path ) , null , $ exception ) ; } // If rescurive set to true, use RecursiveIteratorIterator return $ recursive ? new \ RecursiveIteratorIterator ( $ iterator ) : $ iterator ; }
Create file iterator of current dir.

@param  string  $path      The directory path.
@param  boolean $recursive True to recursive.
@param  integer $options   FilesystemIterator Flags provides which will affect the behavior of some methods.

@throws \InvalidArgumentException
@return  \FilesystemIterator|\RecursiveIteratorIterator  File & dir iterator.
Create file iterator of current dir .