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;
    }