Map the path with the right types.
Take care that paths are not used twice.

@param array  $paths
@param string $type

@return array
491591
protected function mapPathsWithType(array $paths, string $type): array
    {
        return \array_map(function ($item) use ($type) {
            return [
                'path' => $item,
                'type' => $type,
            ];
        }, \array_unique($paths));
    }
575881
public function getMigrationsDefinitions(array $paths = array())
    {
        // we try to be flexible in file types we support, and the same time avoid loading all files in a directory
        $handledDefinitions = array();
        foreach ($this->loader->listAvailableDefinitions($paths) as $migrationName => $definitionPath) {
            foreach ($this->DefinitionParsers as $definitionParser) {
                if ($definitionParser->supports($migrationName)) {
                    $handledDefinitions[] = $definitionPath;
                }
            }
        }

        // we can not call loadDefinitions with an empty array using the Filesystem loader, or it will start looking in bundles...
        if (empty($handledDefinitions) && !empty($paths)) {
            return new MigrationDefinitionCollection();
        }

        return $this->loader->loadDefinitions($handledDefinitions);
    }
193397
public static function mergeAbsPath(array $paths): array
    {
        if (defined('ABSPATH')) {
            $dir = constant('ABSPATH');
            $path = trailingslashit($dir) . 'preflight.toml';

            $paths[] = normalize_path($path);
        }

        return $paths;
    }
1041462
public function path($type, $path = null)
    {
        $instance = sprintf('path.%s', $type);
        $base = $this->basePath;

        // Verificar se foi instanciado um path diferente
        if (array_key_exists($instance, $this->instances)) {
            $base = $this->instances[$instance];
        }

        // Verificar se foi implementado em config
        $key = sprintf('paths.%s', strtolower($type));
        $base = config($key, $base);

        // Verificar se deve colocar a base
        if (substr($base, 0, 2) == './') {
            $base = $this->basePath . DIRECTORY_SEPARATOR . substr($base, 2);
        }

        // Verificar se deve adiconar type no path
        if ($base == $this->basePath) {
            $path = is_null($path) ? $type : $type . DIRECTORY_SEPARATOR . $path;
        }

        // Retornar
        return is_null($path) ? $base : $base . DIRECTORY_SEPARATOR . $path;
    }
579386
private function filter($items, $path, $type)
    {
        if (!$items) {
            return null;
        }

        return array_filter($items, function ($item) use ($path, $type) {
            $itemCopy = $item;

            // key into the value with the given path
            foreach ($path as $key) {
                $itemCopy = $itemCopy[$key];
            }

            if (strtolower($itemCopy) === strtolower($type)) {
                return $item;
            }
        });
    }
1041830
public function writableDirs(array $paths): self
    {
        foreach ($paths as $path) {
            $this->validatePathIsRelativeToProject($path, __METHOD__);
        }
        $this->writableDirs = $paths;

        return $this;
    }
1294885
public function createMap(...$paths)
    {
        $classes = [];

        $this->finder->files()
            ->ignoreUnreadableDirs()
            ->in($paths);

        foreach($this->excludePathPatterns as $exclude)
        {
            $this->finder->notPath($exclude);
        }

        foreach($this->inPathPatterns as $inPath)
        {
            $this->finder->path($inPath);
        }

        foreach($this->names as $name)
        {
            $this->finder->name($name);
        }

        /** @var SplFileInfo $file */
        foreach ($this->finder as $file) {
            $content = file_get_contents($file->getPathname());

            preg_match('^\s*class ([\S]*)\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);

            if (isset($match[1])) {
                $className = '\\'. trim($match[1][0]);
                $offset = $match[1][1];
            } else {
                continue;
            }

            preg_match('|\s*namespace\s*([\S]*)\s*;|', substr($content, 0 , $offset), $match);

            if (isset($match[1]) && trim($match[1]) !== '') {
                $className = '\\' . trim($match[1]) . $className;
            }

            if ($className !== '\\') {
                $classes[$file->getPathname()] = $className;
            }
        }

        return $classes;
    }
437834
public function delete($paths)
    {
        return $this->filesystem->delete(
            collect((array)$paths)
                ->map(function ($path) {
                    return $this->path($path);
                })
                ->values()
                ->all()
        );
    }
868828
private function inPaths($pathInfo, array $paths)
    {
        foreach ($paths as $path) {
            if (preg_match('#'.$path.'#', $pathInfo)) {
                return true;
            }
        }

        return false;
    }
242035
private function normalizePaths(iterable $paths): array
    {
        $separator = DocumentInterface::PATH_SEPARATOR;

        // convert paths like a.b.c to paths that actually should be used a, a.b, a.b.c
        $normalizedPaths = [];
        foreach ($paths as $path) {
            $curPath = '';
            foreach (\explode($separator, $path) as $pathPart) {
                $curPath                   = empty($curPath) === true ? $pathPart : $curPath . $separator . $pathPart;
                $normalizedPaths[$curPath] = true;
            }
        }

        return $normalizedPaths;
    }
345210
public function getFromGateway($type) {
        $mapper = $this->config->getCcTypesMapper();
        $type   = strtolower($type);

        if( array_key_exists($type, $mapper) ) {
            return $mapper[$type];
        }

        return 'OT';
    }
33813
protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
  {
    foreach ($paths as $path => $names) {
      if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) {
        return $path;
      }
    }

    return false;
  }
1357266
protected function validateTypes(Dictionary $types, $path = "")
    {
        $spath = empty($path) ? "" : $path . ".";
        foreach ($types as $key => $value)
        {
            $kpath = $spath . $key;
            if ($value instanceof Dictionary)
            {
                $this->validateTypes($value, $kpath);
            }
            elseif (is_string($value))
            {
                $types[$key] = new Validator($value);
            }
            elseif (!($value instanceof Validator))
            {
                throw new \InvalidArgumentException(
                    "Unknown type: " . Functions::str($value) . " for " . $kpath
                );
            }
        }
    }
1018778
private function getPreparedPaths(array $paths): array
    {
        $fullPaths = [];

        foreach ($paths as $name => $path) {
            if (\is_array($path)) {
                foreach ($path as $p) {
                    $fullPaths[] = \rtrim($this->vendorDir . \DIRECTORY_SEPARATOR . $name . \DIRECTORY_SEPARATOR . $p, '/');
                }
            } else {
                $fullPaths[] = \rtrim($this->vendorDir . \DIRECTORY_SEPARATOR . $name . \DIRECTORY_SEPARATOR . $path, '/');
            }
        }

        return $fullPaths;
    }
233132
public function load($path, $type = null)
    {
        $dir = $this->locator->locate($path);

        $collection = new RouteCollection();
        $collection->addResource(new DirectoryResource($dir, '/\.php$/'));
        foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
            if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) {
                continue;
            }

            if ($class = $this->findClass($file)) {
                $refl = new \ReflectionClass($class);
                if ($refl->isAbstract() || !$refl->implementsInterface('Pablodip\ModuleBundle\Module\ModuleInterface')) {
                    continue;
                }

                $collection->addCollection(parent::load($file->getRealPath(), $type));
            }
        }

        return $collection;
    }
128282
private static function retrieveFilesFromPaths(array $paths): iterable
    {
        if ([] === $paths) {
            return [];
        }

        $pathsToSearch = [];
        $filesToAppend = [];

        foreach ($paths as $path) {
            if (false === file_exists($path)) {
                throw new RuntimeException(
                    sprintf(
                        'Could not find the file "%s".',
                        $path
                    )
                );
            }

            if (is_dir($path)) {
                $pathsToSearch[] = $path;
            } else {
                $filesToAppend[] = $path;
            }
        }

        $finder = new Finder();

        $finder->files()
            ->in($pathsToSearch)
            ->append($filesToAppend)
            ->filter(static function (SplFileInfo $fileInfo): ?bool {
                if ($fileInfo->isLink()) {
                    return false;
                }

                return null;
            })
            ->sortByName()
        ;

        return $finder;
    }
1327627
private function getContent(array $paths, $type)
    {
        $cacheKey = $this->getHashKey($paths);

        if ($this->cacheItemPool->hasItem($cacheKey)) {
            return $this->cacheItemPool->getItem($cacheKey)->get();
        }

        $minifier = 'js' === $type ? new JS() : new CSS();
        $content = '';

        foreach ($paths as $path) {
            foreach ($this->getFiles($path) as $file) {
                $file = $this->fileLocator->locate($file);

                if ($this->isDebug) {
                    $content .= file_get_contents($file);
                } else {
                    $minifier->add($file);
                }
            }
        }

        $content = $this->isDebug ? $content : $minifier->minify();

        $this->cacheItemPool->save($this->cacheItemPool->getItem($cacheKey)->set($content));

        return $content;
    }