DatabaseHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 1
cbo 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createTable() 0 12 2
1
<?php
2
3
/**
4
 * @author   Temitope Olotin <[email protected]>
5
 * @license  <https://opensource.org/license/MIT> MIT
6
 */
7
namespace Laztopaz\PotatoORM;
8
9
class DatabaseHelper
10
{
11
    public $dbConn;
12
13
    /**
14
     * This is a constructor; a default method  that will be called automatically during class instantiation.
15
     */
16
    public function __construct($dbConnect)
17
    {
18
        $this->dbConn = $dbConnect;
19
    }
20
21
    /**
22
     * This method creates a particular table.
23
     *
24
     * @param tableName
25
     * $return boolean true or false
26
     */
27
    public function createTable($tableName, $conn = null)
28
    {
29
        if (is_null($conn)) {
30
            $conn = $this->dbConn;
31
        }
32
33
        $sql = 'CREATE TABLE IF NOT EXISTS '.$tableName.'(';
34
        $sql .= ' id INT( 11 ) AUTO_INCREMENT PRIMARY KEY, name VARCHAR( 100 ), gender VARCHAR( 10 ), alias VARCHAR( 150 ) NOT NULL, class VARCHAR( 150 ), stack VARCHAR( 50 ) )';
35
36
        return $conn->exec($sql);
37
        
38
    }
39
}
40