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

AuraSqlProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 41
ccs 0
cts 13
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 10 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 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