Completed
Push — master ( cea07d...f59d63 )
by Christopher
04:21 queued 01:08
created

ManagerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 28
ccs 9
cts 11
cp 0.8182
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 18 3
1
<?php
2
3
namespace AsyncPHP\Icicle\Database;
4
5
use InvalidArgumentException;
6
7
final class ManagerFactory
8
{
9
    /**
10
     * @param array $config
11
     *
12
     * @return Manager
13
     *
14
     * @throw InvalidArgumentException
15
     */
16 1
    public function create(array $config)
17
    {
18 1
        if (!isset($config["driver"])) {
19
            throw new InvalidArgumentException("Undefined driver");
20
        }
21
22 1
        $connectors = new ConnectorFactory();
23 1
        $builders = new BuilderFactory();
24
25 1
        if ($config["driver"] === "mysql") {
26 1
            return new Manager(
27 1
                $connectors->create($config),
28 1
                $builders->create($config)
29 1
            );
30
        }
31
32
        throw new InvalidArgumentException("Unrecognised driver");
33
    }
34
}
35