forked from php-db/phpdb-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPdoDriverFactory.php
More file actions
42 lines (34 loc) · 1.37 KB
/
PdoDriverFactory.php
File metadata and controls
42 lines (34 loc) · 1.37 KB
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
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace PhpDb\Adapter\Sqlite\Container;
use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Driver\Pdo\Result;
use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Driver\StatementInterface;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Feature\SqliteRowCounter;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo as PdoDriver;
use PhpDb\Container\AdapterManager;
use Psr\Container\ContainerInterface;
final class PdoDriverFactory
{
public function __invoke(ContainerInterface $container): PdoDriverInterface&PdoDriver
{
/** @var AdapterManager $adapterManager */
$adapterManager = $container->get(AdapterManager::class);
/** @var ConnectionInterface&Connection $connectionInstance */
$connectionInstance = $adapterManager->get(Connection::class);
/** @var StatementInterface&Statement $statementInstance */
$statementInstance = $adapterManager->get(Statement::class);
/** @var ResultInterface&Result $resultInstance */
$resultInstance = $adapterManager->get(Result::class);
return new PdoDriver(
$connectionInstance,
$statementInstance,
$resultInstance,
[new SqliteRowCounter()],
);
}
}