Connection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 8 2
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