forked from php-db/phpdb-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformInterfaceFactory.php
More file actions
35 lines (26 loc) · 944 Bytes
/
PlatformInterfaceFactory.php
File metadata and controls
35 lines (26 loc) · 944 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
<?php
declare(strict_types=1);
namespace PhpDb\Adapter\Sqlite\Container;
use PDO;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Adapter\Sqlite\Platform\Sqlite;
use PhpDb\Container\AdapterManager;
use Psr\Container\ContainerInterface;
final class PlatformInterfaceFactory
{
public function __invoke(ContainerInterface $container): PlatformInterface&Sqlite
{
/** @var AdapterManager $adapterManager */
$adapterManager = $container->get(AdapterManager::class);
/** @var array $config */
$config = $container->get('config');
/** @var array $dbConfig */
$dbConfig = $config['db'] ?? [];
/** @var string $driver */
$driver = $dbConfig['driver'];
/** @var PdoDriverInterface|PDO $driverInstance */
$driverInstance = $adapterManager->get($driver);
return new Sqlite($driverInstance);
}
}