in($this->getTotalPath($dirs)); $contents = []; foreach ($finder->depth(0) as $content) { $contents[] = DirContent::make($content); } return $contents; } /** * @param UploadedFile[] $files */ public function uploadFile(array $files): void { foreach ($files as $file) { $this->filesystem->dumpFile($this->getTotalPath($file->getClientOriginalName()), $file->getContent()); } } public function isFile(string $dirs): bool { try { $this->filesystem->readFile($this->getTotalPath($dirs)); } catch (IOException) { return false; } return true; } public function getFile(string $filePath): DirContent { $dirs = explode('/', $filePath); $fileName = array_pop($dirs); $finder = new Finder(); $finder->in($this->getTotalPath(implode('/', $dirs))); foreach ($finder as $file) { if ($file->getFilename() === $fileName) { return DirContent::make($file, $this->filesystem->readFile($this->getTotalPath($filePath))); } } throw new \RuntimeException('File not found'); } private function getTotalPath(string $filePath): string { return $this->dir . '/' . $filePath; } }