Completed
Push — master ( c64d25...ac7c6c )
by Christopher
19:43 queued 17:08
created

BuilderFactory::create()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 3
Ratio 21.43 %

Code Coverage

Tests 6
CRAP Score 3.1406

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 3
loc 14
ccs 6
cts 8
cp 0.75
rs 9.4286
cc 3
eloc 7
nc 3
nop 1
crap 3.1406
1
<?php
2
3
namespace AsyncPHP\Icicle\Database;
4
5
use AsyncPHP\Icicle\Database\Builder\AuraBuilder;
6
use Aura\SqlQuery\QueryFactory;
7
use InvalidArgumentException;
8
9
final class BuilderFactory
10
{
11
    /**
12
     * @param array $config
13
     *
14
     * @return Builder
15
     *
16
     * @throws InvalidArgumentException
17
     */
18 1
    public function create(array $config)
19
    {
20 1
        if (!isset($config["driver"])) {
21
            throw new InvalidArgumentException("Undefined driver");
22
        }
23
24 1 View Code Duplication
        if (!in_array($config["driver"], ["sqlsrv", "mysql", "pgsql", "sqlite"])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
            throw new InvalidArgumentException("Unrecognised driver");
26
        }
27
28 1
        return new AuraBuilder(
29 1
            new QueryFactory($config["driver"])
30 1
        );
31
    }
32
}
33