<?php
 namespace App\Services\EmailCampaign; use App\Models\EmailCampaign; use App\Services\EmailCampaign\Contracts\EmailCampaignDriverInterface; use App\Services\EmailCampaign\Drivers\LocalDriver; use App\Services\EmailCampaign\Drivers\MailchimpDriver; use App\Services\EmailCampaign\Drivers\MailerLiteDriver; use InvalidArgumentException; class EmailCampaignDriverManager { public const DRIVERS = ['local', 'mailchimp', 'mailerlite']; public function resolve(EmailCampaign $campaign): EmailCampaignDriverInterface { $name = $campaign->provider ?: 'local'; return $this->driver($name); } public function driver(string $name): EmailCampaignDriverInterface { return match ($name) { 'local' => app(LocalDriver::class), 'mailchimp' => app(MailchimpDriver::class), 'mailerlite' => app(MailerLiteDriver::class), default => throw new InvalidArgumentException("Unknown email campaign driver: {$name}"), }; } } 