PostgresConnection::getDefaultSchemaGrammar()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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