* * Nextcloud - Two-factor Gateway * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see * */ namespace OCA\TwoFactorGateway\Service\Gateway; use Exception; use OCA\TwoFactorGateway\Service\Gateway\Signal\Gateway as SignalGateway; use OCA\TwoFactorGateway\Service\Gateway\SMS\Gateway as SMSGateway; use OCA\TwoFactorGateway\Service\Gateway\Telegram\Gateway as TelegramGateway; class Factory { /** @var SignalGateway */ private $signalGateway; /** @var SMSGateway */ private $smsGateway; /** @var TelegramGateway */ private $telegramGateway; public function __construct(SignalGateway $signalGateway, SMSGateway $smsGateway, TelegramGateway $telegramGateway) { $this->signalGateway = $signalGateway; $this->smsGateway = $smsGateway; $this->telegramGateway = $telegramGateway; } public function getGateway(string $name): IGateway { switch ($name) { case 'signal': return $this->signalGateway; case 'sms': return $this->smsGateway; case 'telegram': return $this->telegramGateway; default: throw new Exception("Invalid gateway <$name>"); } } }