Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PdoFactory
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 create
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10namespace Phexium\Plugin\PdoFactory\Adapter;
11
12use Override;
13use PDO;
14use Phexium\Plugin\PdoFactory\Internal\MysqlPdoFactory;
15use Phexium\Plugin\PdoFactory\Internal\PostgresqlPdoFactory;
16use Phexium\Plugin\PdoFactory\Internal\SqlitePdoFactory;
17use Phexium\Plugin\PdoFactory\Port\PdoFactoryInterface;
18
19final readonly class PdoFactory implements PdoFactoryInterface
20{
21    public function __construct(
22        private array $env,
23    ) {}
24
25    #[Override]
26    public function create(): PDO
27    {
28        return match ($this->env['database.type'] ?? 'Sqlite') {
29            'Mysql' => new MysqlPdoFactory($this->env)->create(),
30            'Postgresql' => new PostgresqlPdoFactory($this->env)->create(),
31            default => new SqlitePdoFactory($this->env)->create(),
32        };
33    }
34}