Passed
Push — master ( becae5...2d4555 )
by Jean Paul
12:24
created

SqliteConnector::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Coco\SourceWatcher\Core\Database\Connections;
4
5
use Doctrine\DBAL\Connection;
6
7
/**
8
 * Class SqliteConnector
9
 *
10
 * @package Coco\SourceWatcher\Core\Database\Connections
11
 *
12
 * Following the definition from:
13
 *     https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#pdo-sqlite
14
 */
15
class SqliteConnector extends EmbeddedDatabaseConnector
16
{
17
    protected string $path;
18
19
    protected bool $memory;
20
21
    public function __construct ()
22
    {
23
        parent::__construct();
24
25
        $this->driver = "pdo_sqlite";
26
27
        $this->memory = false;
28
    }
29
30
    public function getPath () : string
31
    {
32
        return $this->path;
33
    }
34
35
    public function setPath ( string $path ) : void
36
    {
37
        $this->path = $path;
38
    }
39
40
    public function isMemory () : bool
41
    {
42
        return $this->memory;
43
    }
44
45
    public function setMemory ( bool $memory ) : void
46
    {
47
        $this->memory = $memory;
48
    }
49
50
    public function getConnectionParameters () : array
51
    {
52
        $this->connectionParameters = [
53
            "driver" => $this->driver,
54
            "user" => $this->user,
55
            "password" => $this->password
56
        ];
57
58
        if ( isset( $this->path ) && $this->path !== "" ) {
59
            $this->connectionParameters["path"] = $this->path;
60
        }
61
62
        if ( isset( $this->tableName ) && $this->tableName !== "" ) {
63
            $this->connectionParameters["tableName"] = $this->tableName;
64
        }
65
66
        $this->connectionParameters["memory"] = $this->memory;
67
68
        return $this->connectionParameters;
69
    }
70
71
    protected function executeExtraStatements ( Connection $connection ) : void
72
    {
73
        // TODO: Implement executeExtraStatements() method.
74
    }
75
}
76