Create an iterator for the given file paths.

@param string ...$paths

@return Iterator
193701
private function createFilesIterator(string ...$paths): Iterator
    {
        return new ArrayIterator(
            array_map(
                function (string $path) : SplFileInfo {
                    return new SplFileInfo($path);
                },
                array_filter(
                    $paths,
                    function (string $path) : bool {
                        return is_readable($path);
                    }
                )
            )
        );
    }
1224834
private static function normalizePaths($paths) {
    $re = ['#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'];
    for ($n=1; $n>0; $paths=preg_replace($re, '/', $paths, -1, $n)) {}
    return $paths;
  }
349069
public function getDeployFiles($paths)
    {
        return Collection::make($paths)->flatMap(function ($path) {
            return $this->files->glob($path.'/*.php');
        })->filter()->sortBy(function ($file) {
                return $this->getDeployName($file);
            })->values()->keyBy(function ($file) {
                return $this->getDeployName($file);
            })->all();
    }
496299
public function find($paths = null)
    {
        if ($paths === null) $paths = $this->paths;

        // iterator
        $iterator = $this->getIterator();

        // search in target paths
        foreach ((array)$paths as $path) {
            $this->searchInPath($iterator, $path);
        }

        // clear
        $this->clear();

        return $iterator;
    }
116384
private function setDirectories($paths)
    {
        if (!empty($paths)) {
            foreach ($paths as $key => $dir) {
                $path = str_replace('.', DS, $dir);

                //Iterate through all paths and filter with extension provided
                $recursiveExtensionFilter = new FileExtensionFilter(
                    new \RecursiveDirectoryIterator($path)
                );

                // loop through the directory listing
                // we need to create a RecursiveIteratorIterator instance
                foreach ($recursiveExtensionFilter as $item) {
                    $alias = str_replace('.php', '', $item->getPathName());

                    $alias = implode('\\', array_map('ucfirst', explode(DS, $alias)));
                    if (!isset($this->directories[$alias])) {
                        $this->directories[str_replace('Src', '', $alias)] = str_replace('\\', '/', $item->getPathName());
                    }
                }
            }
        }
    }
169189
private function getDirectoryIterator($path)
    {
        $nodes = new \DirectoryIterator($path);
        $dirs = [];

        foreach ($nodes as $dir) {
            if (!$dir->isDir()) {
                continue;
            }

            if ($dir->isDot()) {
                continue;
            }

            $dirs[hexdec($dir->getFilename())] = $dir->getPathname();
        }

        krsort($dirs);

        return new \ArrayIterator($dirs);
    }
186074
public function prep_paths(array $paths)
	{
		foreach ($paths as &$path)
		{
			$path = $this->prep_path($path);
		}
		return $paths;
	}
1115682
public function addPaths($paths)
    {
        $paths = is_array($paths) ? $paths : [$paths];

        foreach ($paths as $key => $path) {
            $key = is_int($key) ? null : $key;

            $this->addPath($path, $key);
        }

        return $this;
    }
1349185
public static function join($paths)
    {
        $paths = is_array($paths) ? $paths : func_get_args();

        return join(DIRECTORY_SEPARATOR, $paths);
    }
437027
public function addPaths(array $paths)
    {
        $this->currentCollectorData = $this->filePathCollector->collect();

        foreach ($paths as $path) {
            $this->addPath($path);
        }
    }
1245193
private function joinPath(...$paths)
    {
        $resultPath = null;

        foreach($paths as $path) {
            if ($resultPath === null || (!empty($path) && $path[0] === '/')) {
                $resultPath = $path;
            } else {
                $resultPath = $resultPath . '/' . $path;
            }
        }

        $resultPath = preg_replace('~/{2,}~','/', $resultPath);

        if ($resultPath === '/') {
            return '/';
        }

        $resultPathParts = [];
        foreach(explode('/',rtrim($resultPath,'/')) as $part) {
            if ('.' === $part) {
                continue;
            }

            if ('..' === $part && count($resultPathParts) > 0) {
                array_pop($resultPathParts);
                continue;
            }

            $resultPathParts[] = $part;
        }

        return implode('/',$resultPathParts);
    }
877191
public function iterator(array $fields = null)
    {
        return $this->mapper->collection(parent::iterator($fields), $this->definition);
    }
252410
public function getMultipleChildren(array $paths)
    {
        $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
        $children = [];
        foreach ($objs as $obj) {
            $obj['acl'] = $this->getChildACL();
            $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
        }

        return $children;
    }
947855
public function getFlyIterator($flags=null)
    {
        if (is_null($flags)) {
            $flags = self::ITERATOR_DIRECTORY | self::ITERATOR_FILE;
        }

        $recursive = ($flags & self::ITERATOR_RECURSIVE);
        $withDirectories = ($flags & self::ITERATOR_DIRECTORY);
        $withFiles = ($flags & self::ITERATOR_FILE);

        $iterator = array();
        $contents = $this->getFileSystem()->listContents($this->getPrefix(), $recursive);

        foreach ($contents as $content) {
            if ($withDirectories && $content['type'] == 'dir') {
                $iterator[] = $this->getDirectory(str_replace($this->getPrefix(), '', $content['path']));
            }

            if ($withFiles && $content['type'] == 'file') {
                $iterator[] = $this->getFile(str_replace($this->getPrefix(), '', $content['path']));
            }
        }

        return new \ArrayIterator($iterator);
    }
470678
protected function createDirectory($paths)
    {
        if (!is_array($paths)) {
            $paths = array($paths);
        }

        foreach ($paths as $path) {
            if (!is_dir($dir = dirname($path)) && false === @mkdir($dir, 0777, true)) {
                // @codeCoverageIgnoreStart
                throw new \RuntimeException(sprintf('Unable to create directory "%s".', $dir));
                // @codeCoverageIgnoreEnd
            }
        }
    }
1082947
public function addAll(Paths $paths) {
		foreach ($paths as $p) {
			$path = $this->get($p->getPath());
			foreach ($p->getMethods() as $method) {
				$path->setOperation($method, $p->getOperation($method));
			}
		}
	}
266063
public function dirs($paths = false, $createMissing = false)
    {
        if ($paths === false) {
            return $this->find('*')->dirs();
        }

        $list = new Collection;
        foreach ($paths as $path) {
            $list->add($this->dir($path, $createMissing));
        }
        return $list;
    }