Table   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTable() 0 19 2
1
<?php
2
/**
3
 * The Helper class to get Table Name
4
 *
5
 * @author RN Kushwaha <[email protected]>
6
 * @since v0.0.5 <Date: 8th Dec, 2019>
7
 */
8
9
namespace Dolphin\Utils;
10
11
use Dolphin\Builders\QueryBuilder;
12
13
class Table
14
{
15
    /**
16
     * It returns the table name to Query from
17
     * Used internally
18
     */
19
    public function getTable($class)
20
    {
21
        $ref   = new \ReflectionClass($class);
22
        $qb    = new QueryBuilder();
23
        $util  = new Utils();
24
25
        if ($ref->hasProperty('table')) {
26
            $tableCheck = $ref->getProperty('table');
27
            $tableCheck->setAccessible(true);
28
            $tableName = $tableCheck->getValue(new $class());
29
        } else {
30
            $tableName = explode('\\', $class);
31
            $tableName = $util->decamelize(end($tableName));
32
        }
33
34
        $prefix = $qb->getPrefix();
35
        $table = $prefix.$tableName;
36
37
        return $table;
38
    }
39
}
40