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 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0
cc 3
nc 3
nop 5
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Postgres\Connectors;
6
7
use Illuminate\Database\Connection;
8
use Illuminate\Database\Connectors\ConnectionFactory as ConnectionFactoryBase;
9
use Umbrellio\Postgres\PostgresConnection;
10
11
class ConnectionFactory extends ConnectionFactoryBase
12
{
13 29
    protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
14
    {
15 29
        $resolver = Connection::getResolver($driver);
16 29
        if ($resolver) {
17 1
            return $resolver($connection, $database, $prefix, $config);
18
        }
19
20 29
        if ($driver === 'pgsql') {
21 29
            return new PostgresConnection($connection, $database, $prefix, $config);
22
        }
23
24 1
        return parent::createConnection($driver, $connection, $database, $prefix, $config);
25
    }
26
}
27