Completed
Push — master ( 588b5e...a331b6 )
by Matthew
04:08
created

Factory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 0
cbo 2
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 15 4
1
<?php
2
namespace Fyuze\Database\Drivers;
3
4
use InvalidArgumentException;
5
6
class Factory
7
{
8
    /**
9
     * @param array $config
10
     * @return Mysql|Sqlite
11
     * @throws InvalidArgumentException
12
     */
13 10
    public static function create($config)
14
    {
15 10
        if(!array_key_exists('driver', $config)) {
16 1
            throw new InvalidArgumentException('You must specify a driver');
17
        }
18
19 9
        switch ($config['driver']) {
20 9
            case 'mysql':
21 1
                return new Mysql($config);
22 8
            case 'sqlite':
23 7
                return new Sqlite($config);
24 1
            default:
25 1
                throw new InvalidArgumentException('Invalid or no driver specified');
26 1
        }
27
    }
28
}
29