Passed
Pull Request — master (#23)
by Adrien
17:46 queued 04:32
created

Driver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\DBAL\Logging;
6
7
use Doctrine\DBAL\Driver as DriverInterface;
8
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
9
use SensitiveParameter;
10
11
final class Driver extends AbstractDriverMiddleware
12
{
13
    public function __construct(DriverInterface $driver)
14
    {
15
        parent::__construct($driver);
16
    }
17
18
    public function connect(#[SensitiveParameter] array $params): Connection
19
    {
20
        _log()->debug('Connecting to DB', $this->maskPassword($params));
21
22
        return new Connection(parent::connect($params));
23
    }
24
25
    /**
26
     * @param array<string,mixed> $params
27
     *
28
     * @return array<string,mixed>
29
     */
30
    private function maskPassword(#[SensitiveParameter] array $params): array
31
    {
32
        if (isset($params['password'])) {
33
            $params['password'] = '***REDACTED***';
34
        }
35
36
        return $params;
37
    }
38
}
39