AuraSqlMasterModule::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
/**
3
 * This file is part of the Ray.AuraSqlModule package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace Ray\AuraSqlModule;
8
9
use Aura\Sql\ExtendedPdo;
10
use Aura\Sql\ExtendedPdoInterface;
11
use Ray\Di\AbstractModule;
12
use Ray\Di\Scope;
13
14
class AuraSqlMasterModule extends AbstractModule
15
{
16
    /**
17
     * @var string
18
     */
19
    private $dsn;
20
21
    /**
22
     * @var string
23
     */
24
    private $user;
25
26
    /**
27
     * @var string
28
     */
29
    private $password;
30
31 3
    public function __construct(string $dsn, string $user = '', string $password = '', AbstractModule $module = null)
32
    {
33 3
        $this->dsn = $dsn;
34 3
        $this->user = $user;
35 3
        $this->password = $password;
36 3
        parent::__construct($module);
0 ignored issues
show
Bug introduced by
It seems like $module defined by parameter $module on line 31 can also be of type object<Ray\Di\AbstractModule>; however, Ray\Di\AbstractModule::__construct() does only seem to accept null|object<self>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
37 3
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 3
    protected function configure()
43
    {
44 3
        $this->bind(ExtendedPdoInterface::class)->toConstructor(ExtendedPdo::class, 'dsn=pdo_dsn,username=pdo_user,password=pdo_pass,options=pdo_option')->in(Scope::SINGLETON);
45 3
        $this->bind()->annotatedWith('pdo_dsn')->toInstance($this->dsn);
46 3
        $this->bind()->annotatedWith('pdo_user')->toInstance($this->user);
47 3
        $this->bind()->annotatedWith('pdo_pass')->toInstance($this->password);
48 3
        $this->bind()->annotatedWith('pdo_option')->toInstance([]);
49 3
    }
50
}
51