Completed
Push — master ( f5e5fb...7d0a28 )
by Rasmus
02:24
created

PostgresDatabase::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace mindplay\sql\postgres;
4
5
use mindplay\sql\model\Database;
6
use mindplay\sql\model\schema\Table;
7
use mindplay\sql\model\types\BoolType;
8
9
class PostgresDatabase extends Database
10
{
11 1
    public function __construct()
12
    {
13 1
        parent::__construct();
14
15 1
        $this->container->register(BoolType::class, function () {
16
            return BoolType::get(true, false);
17 1
        });
18
        
19 1
        $this->container->alias("scalar.boolean", BoolType::class);
20 1
    }
21
22
    /**
23
     * @param Table $from
24
     *
25
     * @return PostgresSelectQuery
26
     */
27
    public function select(Table $from)
28
    {
29
        return $this->container->create(PostgresSelectQuery::class, ['root' => $from]);
30
    }
31
    
32
    /**
33
     * @param Table $into
34
     *
35
     * @return PostgresInsertQuery
36
     */
37 1
    public function insert(Table $into)
38
    {
39 1
        return $this->container->create(PostgresInsertQuery::class, ['table' => $into]);
40
    }
41
42
    /**
43
     * @param Table $table
44
     *
45
     * @return PostgresUpdateQuery
46
     */
47
    public function update(Table $table)
48
    {
49
        return $this->container->create(PostgresUpdateQuery::class, ['root' => $table]);
50
    }
51
52
    /**
53
     * @param Table $table
54
     *
55
     * @return PostgresDeleteQuery
56
     */
57
    public function delete(Table $table)
58
    {
59
        return $this->container->create(PostgresDeleteQuery::class, ['root' => $table]);
60
    }
61
    
62 1
    protected function createDriver()
63
    {
64 1
        return new PostgresDriver();
65
    }
66
}
67