Failed Conditions
Pull Request — master (#23)
by Adrien
03:02
created

Driver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10
ccs 0
cts 9
cp 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connect() 0 5 1
A maskPassword() 0 7 2
A __construct() 0 3 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()->info('Connecting with parameters {params}', ['params' => $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