ConnectionFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 7
cts 8
cp 0.875
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A createConnection() 0 15 4
1
<?php
2
3
namespace LaravelSpatial\Connectors;
4
5
use LaravelSpatial\MysqlConnection;
6
use LaravelSpatial\PostgresConnection;
7
use PDO;
8
9
/**
10
 * Class ConnectionFactory
11
 *
12
 * @package LaravelSpatial\Connectors
13
 */
14
class ConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactory
15
{
16
    /**
17
     * @param string       $driver
18
     * @param \Closure|PDO $connection
19
     * @param string       $database
20
     * @param string       $prefix
21
     * @param array        $config
22
     *
23
     * @return \Illuminate\Database\ConnectionInterface
24
     * @throws \Doctrine\DBAL\Exception
25
     */
26 27
    protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
27
    {
28 27
        if ($this->container->bound($key = "db.connection.{$driver}")) {
29
            return $this->container->make($key, [$connection, $database, $prefix, $config]);
30
        }
31
32 27
        if ($driver === 'mysql') {
33 13
            return new MysqlConnection($connection, $database, $prefix, $config);
34
        }
35
36 14
        if ($driver === 'pgsql') {
37 13
            return new PostgresConnection($connection, $database, $prefix, $config);
38
        }
39
40 1
        return parent::createConnection($driver, $connection, $database, $prefix, $config);
41
    }
42
}
43