AuraSqlMasterModule::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 1
rs 9.9332
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Aura\Sql\ExtendedPdo;
8
use Aura\Sql\ExtendedPdoInterface;
9
use Override;
10
use Ray\Di\AbstractModule;
11
use Ray\Di\Scope;
12
use SensitiveParameter;
0 ignored issues
show
Bug introduced by
The type SensitiveParameter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
final class AuraSqlMasterModule extends AbstractModule
15
{
16
    /**
17
     * @phpstan-param array<string> $options
18
     * @phpstan-param array<string> $attributes
19
     */
20
    public function __construct(
21
        private readonly string $dsn,
22
        private readonly string $user = '',
23
        #[SensitiveParameter]
24
        private readonly string $password = '',
25
        /** @var array<string> */
26
        private readonly array $options = [],
27
        /** @var array<string> */
28
        private readonly array $attributes = [],
29
        ?AbstractModule $module = null
30
    ) {
31
        parent::__construct($module);
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    #[Override]
38
    protected function configure(): void
39
    {
40
        $this->bind(ExtendedPdoInterface::class)->toConstructor(
41 3
            ExtendedPdo::class,
42
            'dsn=pdo_dsn,username=pdo_user,password=pdo_pass,options=pdo_option,attributes=pdo_attributes',
43 3
        )->in(Scope::SINGLETON);
44 3
        $this->bind()->annotatedWith('pdo_dsn')->toInstance($this->dsn);
45 3
        $this->bind()->annotatedWith('pdo_user')->toInstance($this->user);
46 3
        $this->bind()->annotatedWith('pdo_pass')->toInstance($this->password);
47 3
        $this->bind()->annotatedWith('pdo_option')->toInstance($this->options);
48 3
        $this->bind()->annotatedWith('pdo_attributes')->toInstance($this->attributes);
49 3
    }
50
}
51