public static function read(string $path, string $filter = null): array
    {
        if (is_dir($path) && $handle = opendir($path)) {
            $files = [];

            if (substr($path, -1) != '/') {
                $path .= '/';
            }

            while (false !== ($entry = readdir($handle))) {
                if ($entry !== '.' && $entry !== '..') {
                    if ($filter === null || preg_match($filter, $entry)) {
                        $fullPath = $path . $entry;

                        if (substr($fullPath, 0, 1) == '.') {
                            $fullPath = stream_resolve_include_path($path . $entry);
                        }

                        $files[$fullPath] = $entry;
                    }
                }
            }

            return $files;
        } else {
            throw new FilesystemException("Unable to open directory on path={$path}");
        }
    }