$builderServices */ public function __construct( private readonly iterable $builderServices, ) { } /** * Itère sur les services de build disponibles et * retourne le premier qui supporte ce type de requête. * * @throws \Exception */ public function getBuilderFor(MailerModelInterface $mailerModel): BuilderInterface { /** @var BuilderInterface $builderService */ foreach ($this->builderServices as $builderService) { if ($builderService->support($mailerModel)) { return $builderService; } } throw new \RuntimeException('no builder service found for this operation'); } }