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

PostgresDatabase   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 0
cbo 4
dl 0
loc 58
ccs 10
cts 10
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A select() 0 4 1
A insert() 0 4 1
A update() 0 4 1
A delete() 0 4 1
A createDriver() 0 4 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