PostgresConnection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getDefaultSchemaGrammar() 0 3 1
A getSchemaBuilder() 0 7 2
1
<?php namespace LaravelSpatial;
2
3
use LaravelSpatial\Schema\Grammars\PostgresGrammar;
4
use LaravelSpatial\Schema\PostgresBuilder;
5
6
/**
7
 * Class PostgresConnection
8
 *
9
 * @package LaravelSpatial
10
 */
11
class PostgresConnection extends \Illuminate\Database\PostgresConnection
12
{
13
    /**
14
     * @inheritDoc
15
     * @throws \Doctrine\DBAL\Exception
16
     */
17 15
    public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
18
    {
19 15
        parent::__construct($pdo, $database, $tablePrefix, $config);
20
21
        // Prevent geography type fields from throwing a 'type not found' error.
22 15
        $this->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('geography', 'string');
23 15
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28 13
    public function getSchemaBuilder()
29
    {
30 13
        if ($this->schemaGrammar === null) {
31 13
            $this->useDefaultSchemaGrammar();
32
        }
33
34 13
        return new PostgresBuilder($this);
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40 13
    protected function getDefaultSchemaGrammar()
41
    {
42 13
        return $this->withTablePrefix(new PostgresGrammar());
43
    }
44
}
45