placeInfo->getPlace(); } /** * @return never */ public function setName($name): never { throw new Forbidden('Cannot change the place collection name'); } /** * @param string $name * @param null|resource|string $data * @return never */ public function createFile($name, $data = null): never { throw new Forbidden('Cannot create a file in a place collection'); } /** * @return never */ public function createDirectory($name): never { throw new Forbidden('Not allowed to create directories in this folder'); } /** * @return PlacePhoto[] */ public function getChildren(): array { if ($this->children === null) { $this->children = array_map( fn (PlaceFile $file): PlacePhoto => new PlacePhoto($this->placeInfo, $file, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)), $this->placeMapper->findFilesForUserAndPlace($this->placeInfo->getUserId(), $this->placeInfo->getPlace()) ); } return $this->children; } public function getChild($name): PlacePhoto { try { [$fileId, $fileName] = explode('-', (string)$name, 2); $placeFile = $this->placeMapper->findFileForUserAndPlace($this->placeInfo->getUserId(), $this->placeInfo->getPlace(), $fileId, $fileName); return new PlacePhoto($this->placeInfo, $placeFile, $this->rootFolder, $this->rootFolder->getUserFolder($this->userId)); } catch (NotFoundException $ex) { throw new NotFound("File $name not found", 0, $ex); } } public function childExists($name): bool { try { $this->getChild($name); return true; } catch (NotFound) { return false; } } public function getLastModified(): int { return 0; } public function getFirstPhoto(): int { $children = $this->getChildren(); if (count($children) === 0) { throw new \Exception('No children found for place'); } return $children[0]->getFileId(); } /** * @return int[] */ public function getFileIds(): array { return array_map(fn (PlacePhoto $file): int => $file->getFileId(), $this->getChildren()); } }