ConnectionFactory::createConnection()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 0
loc 12
ccs 4
cts 5
cp 0.8
rs 9.4285
cc 3
eloc 6
nc 3
nop 5
crap 3.072
1
<?php namespace Bosnadev\Database\Connectors;
2
3
use Bosnadev\Database\PostgresConnection;
4
5
/**
6
 * Class ConnectionFactory
7
 * @package Bosnadev\Database\Connectors
8
 */
9
class ConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactory
10
{
11
    /**
12
     * Create a new connection instance.
13
     *
14
     * @param  string   $driver
15
     * @param  \PDO|\Closure     $connection
16
     * @param  string   $database
17
     * @param  string   $prefix
18
     * @param  array    $config
19
     * @return \Illuminate\Database\Connection
20
     *
21
     * @throws \InvalidArgumentException
22
     */
23
    protected function createConnection($driver, $connection, $database, $prefix = '', array $config = array())
24
    {
25
        if ($this->container->bound($key = "db.connection.{$driver}")) {
26
            return $this->container->make($key, array($connection, $database, $prefix, $config));
27 3
        }
28
29 3
        if ($driver === 'pgsql') {
30
            return new PostgresConnection($connection, $database, $prefix, $config);
31
        }
32
33 3
        return parent::createConnection($driver, $connection, $database, $prefix, $config);
34 3
    }
35
}
36