25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

35 satır
760B

  1. <?php
  2. namespace Framework\Email;
  3. use Closure;
  4. use Framework\Email\Driver\Driver;
  5. use Framework\Email\Exception\DriverException;
  6. use Framework\Support\DriverFactory;
  7. class Factory implements DriverFactory
  8. {
  9. protected array $drivers;
  10. public function addDriver(string $alias, Closure $driver): static
  11. {
  12. $this->drivers[$alias] = $driver;
  13. return $this;
  14. }
  15. public function connect(array $config): Driver
  16. {
  17. if (!isset($config['type'])) {
  18. throw new DriverException('type is not defined');
  19. }
  20. $type = $config['type'];
  21. if (isset($this->drivers[$type])) {
  22. return $this->drivers[$type]($config);
  23. }
  24. throw new DriverException('unrecognised type');
  25. }
  26. }

Powered by TurnKey Linux.