Completed
Pull Request — master (#4)
by Rougin
03:41
created

AbstractDriver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getQuery() 0 15 3
1
<?php
2
3
namespace Rougin\Describe\Driver;
4
5
/**
6
 * Abstract Driver
7
 *
8
 * @package  Describe
9
 * @category Driver
10
 * @author   Rougin Royce Gutib <[email protected]>
11
 */
12
abstract class AbstractDriver
13
{
14
    /**
15
     * @var \PDO
16
     */
17
    protected $pdo;
18
19
    /**
20
     * Returns the list of columns based on the specified query.
21
     *
22
     * @param  string $tableName
23
     * @param  string $query
24
     * @return void
25
     */
26 66
    public function getQuery($tableName, $query)
27
    {
28
        try {
29 66
            $information = $this->pdo->prepare($query);
30
31 66
            $information->execute();
32 66
            $information->setFetchMode(\PDO::FETCH_OBJ);
33 66
        } catch (\PDOException $e) {
34
            // Table not found
35
        }
36
37 66
        while ($row = $information->fetch()) {
38 60
            $this->setColumn($tableName, $row);
39 60
        }
40 66
    }
41
}
42