Database::connect()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
    class Database {
4
5
        // Database Params
6
        private $host = "localhost";
7
        private $db_name = "minska";
8
        private $username = "root";
9
        private $password = "";
10
11
        public $conn;
12
        public function connect() {
13
14
            $this->conn = null;
15
16
            try {
17
18
                $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
19
20
            } catch (PDOException $exception) {
21
22
                echo "Connection error: " . $exception->getMessage();
23
24
            }
25
26
            return $this->conn;
27
28
        }
29
30
    }
31
32
33