Completed
Push — 1.x ( 980d56...edf1de )
by Akihito
14s queued 12s
created

AuraSqlBaseModule::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Ray\AuraSqlModule\Pagerfanta\AuraSqlPagerModule;
8
use Ray\Di\AbstractModule;
9
10
use function preg_match;
11
12
class AuraSqlBaseModule extends AbstractModule
13
{
14
    private string $dsn;
15
16
    public function __construct(string $dsnKey, ?AbstractModule $module = null)
17
    {
18
        $this->dsn = $dsnKey;
19
        parent::__construct($module);
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function configure(): void
26
    {
27
        // @Transactional
28
        $this->install(new TransactionalModule());
29
        $this->install(new AuraSqlPagerModule());
30
        preg_match(AuraSqlModule::PARSE_PDO_DSN_REGEX, $this->dsn, $parts);
31
        $dbType = $parts[1] ?? '';
32
        $this->install(new AuraSqlQueryModule($dbType));
33
    }
34
}
35