AuraSqlEnvModule   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 16
c 2
b 0
f 0
dl 0
loc 46
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
A configure() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Ray\Di\AbstractModule;
8
9
class AuraSqlEnvModule extends AbstractModule
10
{
11
    private string $dsn;
12
    private string $username;
13
    private string $password;
14
    private string $slave;
15
16
    /** @var array<string> */
17
    private array $options;
18
19
    /** @var array<string> */
20
    private array $queries;
21
22
    /**
23
     * @param string        $dsnKey      Env key for Data Source Name (DSN)
24
     * @param string        $usernameKey Env key for Username for the DSN string
25
     * @param string        $passwordKey Env key for Password for the DSN string
26
     * @param string        $slaveKey    Env key for Comma separated slave host list
27
     * @param array<string> $options     A key=>value array of driver-specific connection options
28
     * @param array<string> $queries     Queries to execute after the connection.
29
     */
30
    public function __construct(
31
        string $dsnKey,
32
        string $usernameKey = '',
33
        string $passwordKey = '',
34
        string $slaveKey = '',
35
        array $options = [],
36
        array $queries = []
37
    ) {
38
        $this->dsn = $dsnKey;
39
        $this->username = $usernameKey;
40
        $this->password = $passwordKey;
41
        $this->slave = $slaveKey;
42
        $this->options = $options;
43
        $this->queries = $queries;
44
45
        parent::__construct();
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    protected function configure(): void
52
    {
53
        $this->install(new NamedPdoEnvModule('', $this->dsn, $this->username, $this->password, $this->slave, $this->options, $this->queries));
54
        $this->install(new AuraSqlBaseModule($this->dsn));
55
    }
56
}
57