pool[$key])) { return false; } $this->pool[$key] = $db; return true; } /** * Get database. * * @param string $key Database key * * @return ConnectionAbstract * * @since 1.0.0 */ public function get(string $key = '') : ConnectionAbstract { if ((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { return new NullConnection(); } $con = empty($key) ? \reset($this->pool) : $this->pool[$key]; if ($con->getStatus() !== DatabaseStatus::OK) { $con->connect(); } return $con; } /** * Remove database. * * @param string $key Database key * * @return bool * * @since 1.0.0 */ public function remove(string $key) : bool { if (!isset($this->pool[$key])) { return false; } unset($this->pool[$key]); return true; } /** * Create database. * * @param string $key Database key * @param array{db:string, database:string}|array{db:string, host:string, port:int, login:string, password:string, database:string} $config Database config data * * @return bool * * @since 1.0.0 */ public function create(string $key, array $config) : bool { if (isset($this->pool[$key])) { return false; } $this->pool[$key] = ConnectionFactory::create($config); return true; } }