forked from php-db/phpdb-pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformInterfaceFactory.php
More file actions
36 lines (32 loc) · 1011 Bytes
/
PlatformInterfaceFactory.php
File metadata and controls
36 lines (32 loc) · 1011 Bytes
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
35
36
<?php
declare(strict_types=1);
namespace PhpDb\Pgsql\Container;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Exception\ContainerException;
use PhpDb\Pgsql;
use Psr\Container\ContainerInterface;
final class PlatformInterfaceFactory
{
/**
* @throws ContainerException
*/
public function __invoke(
ContainerInterface $container,
string $requestedName,
?array $options = null
): PlatformInterface&Pgsql\AdapterPlatform {
$driver = $options['driver'] ?? null;
if (
! $driver instanceof Pgsql\Driver
&& ! $driver instanceof Pgsql\Pdo\Driver
) {
// todo: Once latest PR is merged for 0.5.0 update to use PhpDB\Exception\ContainerException
throw ContainerException::forService(
PlatformInterface::class,
self::class,
'Invalid or missing driver provided'
);
}
return new Pgsql\AdapterPlatform($driver);
}
}