$storageServices */ public function __construct( readonly private iterable $storageServices, ) { } public function getStorages(): iterable { return $this->storageServices; } /** * Itère sur les services de storage disponibles et * retourne le premier qui supporte ce type de requête. * * @throws \Exception */ public function getStorageFor(File $file): FileStorageInterface { /** @var FileStorageInterface $storageService */ foreach ($this->storageServices as $storageService) { if ($storageService->support($file)) { return $storageService; } } throw new \RuntimeException('no storage service found for this File'); } }