Completed
Push — develop ( 46fc2d...d666cf )
by Christopher
29:58 queued 15:02
created

Connection::db()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6667
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Ganga\Potato;
4
5
use SQLite3;
6
/**
7
 * Class to define connection to sqlite database;
8
 */
9
class Connection
10
{
11
    protected $conn;
12
13
    /**
14
     * Constructor
15
     * Declare an instance of SQLite class
16
     */
17
    public function __construct($dbFile)
18
    {
19
        $this->conn = new SQLite3($dbFile);
20
    }
21
22
    /**
23
     * Get an instance of the db connection
24
     * @return SQLite3 connection
25
     */
26
    public function db()
27
    {
28
        if (!$this->conn) {
29
            // Throw connection error
30
            return $this->conn->lastErrorMsg();
31
        } else {
32
            return $this->conn;
33
        }
34
    }
35
}
36