Completed
Pull Request — master (#1)
by Matthew
01:34
created

Connection::__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 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
namespace Fyuze\Database;
3
4
use Fyuze\Database\Drivers\Factory;
5
use Fyuze\Database\Drivers\ConnectionInterface;
6
7
class Connection
8
{
9
    /**
10
     * @var Db
11
     */
12
    protected $database;
13
14
    /**
15
     * @var bool
16
     */
17
    protected $connected = false;
18
19
    /**
20
     * @param array $config
21
     */
22
    public function __construct($config)
23
    {
24
        $this->initialize($config);
25
    }
26
27
    /**
28
     * @param $config
29
     */
30
    protected function initialize($config)
31
    {
32
        /** @var ConnectionInterface $factory */
33
        $driver = Factory::create($config);
34
35
        $this->database = new Db($driver);
36
    }
37
38
    /**
39
     * @param $method
40
     * @param $params
41
     * @return mixed
42
     */
43
    public function __call($method, $params)
44
    {
45
        return call_user_func_array([$this->database, $method], $params);
46
    }
47
}
48