ExistingConnection.php 628 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Migrations\Configuration\Connection;
  4. use Doctrine\DBAL\Connection;
  5. use Doctrine\Migrations\Configuration\Exception\InvalidLoader;
  6. final class ExistingConnection implements ConnectionLoader
  7. {
  8. /** @var Connection */
  9. private $connection;
  10. public function __construct(Connection $connection)
  11. {
  12. $this->connection = $connection;
  13. }
  14. public function getConnection(?string $name = null): Connection
  15. {
  16. if ($name !== null) {
  17. throw InvalidLoader::noMultipleConnections($this);
  18. }
  19. return $this->connection;
  20. }
  21. }