Completed
Push — 1.x ( da3088...8894e6 )
by Akihito
02:42
created

AuraSqlProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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
use Ray\AuraSqlModule\Annotation\AuraSqlConfig;
11
use Ray\Di\ProviderInterface;
12
13
class AuraSqlProvider implements ProviderInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $dsn;
19
20
    /**
21
     * @var string
22
     */
23
    private $user;
24
25
    /**
26
     * @var string
27
     */
28
    private $password;
29
30
    /**
31
     * @param array $config
32
     *
33
     * @AuraSqlConfig
34
     */
35
    public function __construct(array $config)
36
    {
37
        list($this->dsn, $this->user, $this->password) = $config;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function get()
44
    {
45
        $pdo = new ExtendedPdo(
46
            $this->dsn,
47
            $this->user,
48
            $this->password
49
        );
50
51
        return $pdo;
52
    }
53
}
54