Better default connection return

This commit is contained in:
Dennis Eichhorn 2017-09-22 19:13:02 +02:00
parent a1a7420654
commit 684d6369a8

View File

@ -77,10 +77,14 @@ class DatabasePool
*
* @since 1.0.0
*/
public function get(string $key = 'core') /* : ?ConnectionAbstract */
public function get(string $key = '') /* : ?ConnectionAbstract */
{
if (!isset($this->pool[$key])) {
return null; /* todo: return nullconnection */
if((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) {
return null;
}
if(empty($key)) {
return reset($this->pool);
}
return $this->pool[$key];