@param $path

@return array
768395
protected function loadDirectory($path) {
        $configs = [];

        if ($this->matchEnvironment($path)) {
            $files = directory_list_files($path);
            $directories = directory_list_directories($path);

            $files = array_merge($files, $directories);

            foreach ($files as $file) {
                $nextPath = path($path, $file);
                $configs[] = $this->loadPath($nextPath);
            }
        }

        return $this->processConfiguration($configs);
    }
96278
public function readStream($path)
    {
        try {
            return [
                'stream' => $this->api->content($path),
                'path' => $path,
            ];
        } catch (\Exception $e) {
            return false;
        }
    }
1183234
public function children($path = ''): array
    {
        if ($path) {
            $parts = $this->split($path);
            $name = array_shift($parts);

            $children = [];
            if (isset($this->subTrees[$name])) {
                $subtree = $this->subTrees[$name];
                $this->appendChildren(
                    $children, $name, $subtree->children($parts)
                );
            }
        } else {
            $children = $this->own();
            foreach ($this->subTrees as $name => $subtree) {
                $this->appendChildren(
                    $children, $name, $subtree->children()
                );
            }
        }

        return $children;
    }
911803
public function getEntities($path)
    {
        $entities = [];

        $Directory = new \RecursiveDirectoryIterator($path);
        $Iterator = new \RecursiveIteratorIterator($Directory);
        $objects = new \RegexIterator($Iterator, '/.*(.php)$/', \RecursiveRegexIterator::GET_MATCH);

        foreach ($objects as $filename => $object) {
            $file = explode('/', $filename);
            if (!preg_filter($this->ignoredFolder, [], $file)) {
                $classname = $this->getNamespace($filename) . NAMESPACE_SEPARATOR . substr(basename($filename), 0, -4);
                if ($this->isValidNamespace($classname)) {
                    $entities[] = $classname;
                }
            }
        }

        return $entities;
    }
32572
public function readDir(string $path): array
    {
        $path = $this->sanitizeDirPath($path);

        if (!$this->dirExists($path)) {
            throw new DirNotFoundException("Dir not found: '$path'");
        }

        $result = $this->readDirRaw($path);

        sort($result);

        return $result;
    }
1247236
public function getMigrationFiles($path)
    {
        $files = Helpers::rGlob($path.'/*_*.php');

        if ($files === false) {
            return [];
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        sort($files);

        return $files;
    }
470826
public function ls(string $path = '') : array
    {
        return version_compare(PHP_VERSION, '7.2.0', '>=')
            ? $this->ls72($path)
            : $this->lsLegacy($path);

    }
97586
private function detectParameters(string $path):array
    {
        $params = array();

        for ($i = 0; $i < strlen($path); $i++) {
            if ($path[$i] == "{") {
                $param = "";
                for (($p = $i + 1); $p < strlen($path); $p++) {
                    if ($path[$p] == "}") {
                        $p = strlen($path);
                        array_push($params, $param);
                    } else {
                        $param = $param.$path[$p];
                    }
                }
            }
        }
        return ($params);
    }
703074
public static function driversIn($path)
    {
        if (! is_dir($path)) {
            return [];
        }

        $drivers = [];

        $dir = new RecursiveDirectoryIterator($path);
        $iterator = new RecursiveIteratorIterator($dir);
        $regex = new RegexIterator($iterator, '/^.+ValetDriver\.php$/i', RecursiveRegexIterator::GET_MATCH);

        foreach ($regex as $file) {
            require_once $file[0];

            $drivers[] = basename($file[0], '.php');
        }

        return $drivers;
    }
1345790
protected function getSegments(string $path): array
    {
        if ('' !== $path && '/' === $path[0]) {
            $path = substr($path, 1);
        }

        return explode('/', $path);
    }
1041917
public function fileDetails($path)
    {
        $path = '/'.ltrim($path, '/');

        return [
            'name'     => basename($path),
            'fullPath' => $path,
            'webPath'  => $this->fileWebPath($path),
            'mimeType' => $this->fileMimeType($path),
            'size'     => $this->fileSize($path),
        ];
    }
226968
public function getMetadata($path)
    {
        $data = Response::parseResponse(
            $this->getCos()->stat($this->getBucket(), $path)
        );

        return $data['data'];
    }
236440
protected function extractQueryString($path)
    {
        if (($queryPosition = strpos($path, '?')) !== false) {
            return [
                substr($path, 0, $queryPosition),
                substr($path, $queryPosition),
            ];
        }

        return [$path, ''];
    }
521873
private function getPathFromArray($path)
    {
        $paths = array();

        foreach ($path as $unverifiedPath) {
            try {
                // Check if `$unverifiedPath` is optional
                // If it exists, then it's added to the list
                // If it doesn't, it throws an exception which we catch
                if ($unverifiedPath[0] !== '?') {
                    $paths = array_merge($paths, $this->getValidPath($unverifiedPath));
                    continue;
                }
                $optionalPath = ltrim($unverifiedPath, '?');
                $paths = array_merge($paths, $this->getValidPath($optionalPath));

            } catch (FileNotFoundException $e) {
                // If `$unverifiedPath` is optional, then skip it
                if ($unverifiedPath[0] === '?') {
                    continue;
                }
                // Otherwise rethrow the exception
                throw $e;
            }
        }

        return $paths;
    }
489926
private function getFiles($path)
    {
        $files = array();

        foreach (new \DirectoryIterator($path) as $file) {
            if ($file->isDot()
                || (null != $this->scriptName && sprintf('%s.php', $this->scriptName) != $file->getFilename())
            ) {
                continue;
            }

            $files[$file->getFilename()] = sprintf('%s/%s', $file->getPath(), $file->getFilename());
        }
        sort($files);

        return $files;
    }
1165632
private function getModules(string $path) : array
    {
        $result = [];
        foreach (Utility::findDirs($path) as $module) {
            if (! $this->isModule($module)) {
                continue;
            }

            $result[] = $module;
        }

        return $result;
    }
45304
public function read($path)
    {
        if ($response = $this->readStream($path)) {
            return ['contents' => stream_get_contents($response['stream']), 'path' => $response['path']];
        }

        return false;
    }