17 private const ITEM_LIST = [
18 self::CODE_DISK => Disk\Base::class,
19 self::CODE_IO => IO\Base::class,
22 private $errorList = [];
25 private static $instance;
32 if (self::$instance ===
null)
37 return self::$instance;
48 public function get(
string $code, array $setting = []): ?
ProviderBase
52 $class = self::ITEM_LIST[$code];
55 $result = $this->getProvider($class, $setting);
61 private function getProvider(
string $class, array $setting = []): ?
ProviderBase
64 if ($class && class_exists($class))
69 $object =
new $class($setting);
77 $this->setError($error->getCode(), $error->getMessage());
84 private function __construct()
88 private function __clone()
92 private function setError($code, $message): void
94 $this->errorList[$code] = $message;
97 private function resetErrors(): bool
99 $this->errorList = [];
106 return $this->errorList;