Passed
Push — master ( 6021d7...3aed48 )
by Jean Paul
06:27
created

SqliteConnector   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 72
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 3 1
A setMemory() 0 3 1
A isMemory() 0 3 1
A __construct() 0 5 1
A setPath() 0 3 1
A getConnectionParameters() 0 15 3
1
<?php
2
3
namespace Coco\SourceWatcher\Core\Database\Connections;
4
5
/**
6
 * Class SqliteConnector
7
 * @package Coco\SourceWatcher\Core\Database\Connections
8
 *
9
 * Following the definition from: https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#pdo-sqlite
10
 */
11
class SqliteConnector extends EmbeddedDatabaseConnector
12
{
13
    /**
14
     * @var string
15
     */
16
    protected string $path;
17
18
    /**
19
     * @var bool
20
     */
21
    protected bool $memory;
22
23
    /**
24
     * SqliteConnector constructor.
25
     */
26
    public function __construct ()
27
    {
28
        $this->driver = "pdo_sqlite";
29
30
        $this->memory = false;
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getPath () : string
37
    {
38
        return $this->path;
39
    }
40
41
    /**
42
     * @param string $path
43
     */
44
    public function setPath ( string $path ) : void
45
    {
46
        $this->path = $path;
47
    }
48
49
    /**
50
     * @return bool
51
     */
52
    public function isMemory () : bool
53
    {
54
        return $this->memory;
55
    }
56
57
    /**
58
     * @param bool $memory
59
     */
60
    public function setMemory ( bool $memory ) : void
61
    {
62
        $this->memory = $memory;
63
    }
64
65
    /**
66
     * @return array
67
     */
68
    protected function getConnectionParameters () : array
69
    {
70
        $this->connectionParameters = array();
71
72
        $this->connectionParameters["driver"] = $this->driver;
73
        $this->connectionParameters["user"] = $this->user;
74
        $this->connectionParameters["password"] = $this->password;
75
76
        if ( isset( $this->path ) && $this->path !== "" ) {
77
            $this->connectionParameters["path"] = $this->path;
78
        }
79
80
        $this->connectionParameters["memory"] = $this->memory;
81
82
        return $this->connectionParameters;
83
    }
84
}
85