Connection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
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
11
/**
12
 * This file is part of the Ray.AuraSqlModule package
13
 *
14
 * @license http://opensource.org/licenses/MIT MIT
15
 */
16
class Connection
17
{
18
    /**
19
     * @var string
20
     */
21
    private $dsn;
22
23
    /**
24
     * @var string
25
     */
26
    private $id;
27
28
    /**
29
     * @var string
30
     */
31
    private $password;
32
33
    /**
34
     * @var ExtendedPdo
35
     */
36
    private $pdo;
37
38 9
    public function __construct(string $dsn, string $id = '', string $password = '')
39
    {
40 9
        $this->dsn = $dsn;
41 9
        $this->id = $id;
42 9
        $this->password = $password;
43 9
    }
44
45 11
    public function __invoke()
46
    {
47 11
        if (! $this->pdo) {
48 9
            $this->pdo = new ExtendedPdo($this->dsn, $this->id, $this->password);
49
        }
50
51 11
        return $this->pdo;
52
    }
53
}
54