Completed
Push — master ( 0ef884...67a9c4 )
by Christopher
02:54
created

ConnectionFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 3
1
<?php
2
3
namespace AsyncPHP\Icicle\Database;
4
5
use AsyncPHP\Icicle\Database\Connection\MySQLConnection;
6
use InvalidArgumentException;
7
8
final class ConnectionFactory
9
{
10
    /**
11
     * @param array $config
12
     *
13
     * @return Connection
14
     *
15
     * @throw InvalidArgumentException
16
     */
17
    public function create(array $config)
18
    {
19
        if (!isset($config["driver"])) {
20
            throw new InvalidArgumentException("Undefined connection driver");
21
        }
22
23
        if ($config["driver"] === "mysql") {
24
            return new MySQLConnection($config);
0 ignored issues
show
Unused Code introduced by
The call to MySQLConnection::__construct() has too many arguments starting with $config.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
        }
26
27
        throw new InvalidArgumentException("Unrecognised connection driver");
28
    }
29
}
30