diff --git a/src/Connection/ConnectionManager.php b/src/Connection/ConnectionManager.php index 26517222..9c814d3c 100644 --- a/src/Connection/ConnectionManager.php +++ b/src/Connection/ConnectionManager.php @@ -65,21 +65,14 @@ public function registerConnection(Connection $connection) */ public function getConnection($alias = null) { - $message = null; - - if (null === $alias && empty($this->connections)) { - $message = sprintf('There is no connection configured'); - } elseif (null !== $alias && !array_key_exists($alias, $this->connections)) { - $message = sprintf('The connection with alias "%s" is not configured', $alias); - } - if ($message) { - throw new InvalidConnectionException($message); - } - if (null === $alias) { return $this->getDefaultConnection(); } + if (!array_key_exists($alias, $this->connections)) { + throw new InvalidConnectionException(sprintf('The connection with alias "%s" is not configured', $alias)); + } + return $this->connections[$alias]; }