25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace Framework\Filesystem;
-
- use Closure;
- use Framework\Filesystem\Driver\Driver;
- use Framework\Filesystem\Exception\DriverException;
- use Framework\Support\DriverFactory;
-
- class Factory implements DriverFactory
- {
- protected array $drivers;
-
- public function addDriver(string $alias, Closure $driver): static
- {
- $this->drivers[$alias] = $driver;
- return $this;
- }
-
- public function connect(array $config): Driver
- {
- if (!isset($config['type'])) {
- throw new DriverException('type is not defined');
- }
-
- $type = $config['type'];
-
- if (isset($this->drivers[$type])) {
- return $this->drivers[$type]($config);
- }
-
- throw new DriverException('unrecognised type');
- }
- }
|