blob: 12b40c02cff40720a5f5529447dc83bc76010912 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tools\Console\ConnectionProvider;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Tools\Console\ConnectionNotFound;
use Doctrine\DBAL\Tools\Console\ConnectionProvider;
use function sprintf;
class SingleConnectionProvider implements ConnectionProvider
{
public function __construct(
private readonly Connection $connection,
private readonly string $defaultConnectionName = 'default',
) {
}
public function getDefaultConnection(): Connection
{
return $this->connection;
}
public function getConnection(string $name): Connection
{
if ($name !== $this->defaultConnectionName) {
throw new ConnectionNotFound(sprintf('Connection with name "%s" does not exist.', $name));
}
return $this->connection;
}
}
|