name = $name; $this->configuration = $configuration; Ulmus::registerAdapter($this, $default); } public function resolveConfiguration() : void { $connection = $this->configuration['connections'][$this->name] ?? []; if ( false !== ( $adapterName = $connection['adapter'] ?? false ) ) { $this->adapter = $this->instanciateAdapter($adapterName); } else { throw new \InvalidArgumentException("Adapter not found within your configuration array."); } $this->adapter->setup($connection); } /** * Connect the adapter * @return self */ public function connect() : self { $this->pdo = $this->adapter->connect(); return $this; } public function adapter() : AdapterInterface { return $this->adapter; } /** * Instanciate an adapter which interact with the data source * @param string $name An Ulmus adapter or full class name implementing AdapterInterface * @return AdapterInterface */ protected function instanciateAdapter($name) : AdapterInterface { $class = substr($name, 0, 2) === "\\" ? $name : "\\Ulmus\\Adapter\\$name"; return new $class(); } }