Passed
Branch master (10fdc5)
by Beniamin
02:43
created

TableRegistry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 34
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerTable() 0 6 1
A getTableClass() 0 8 2
1
<?php
2
3
namespace Phuria\UnderQuery;
4
5
/**
6
 * This file is part of Phuria SQL Builder package.
7
 *
8
 * Copyright (c) 2016 Beniamin Jonatan Šimko
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use Phuria\UnderQuery\Table\UnknownTable;
15
16
/**
17
 * @author Beniamin Jonatan Šimko <[email protected]>
18
 */
19
class TableRegistry
20
{
21
    /**
22
     * @var array $tables
23
     */
24
    private $tableNameMap = [];
25
26
    /**
27
     * @param string $tableClass
28
     * @param string $tableName
29
     *
30
     * @return $this
31
     */
32
    public function registerTable($tableClass, $tableName)
33
    {
34
        $this->tableNameMap[$tableName] = $tableClass;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param string $tableName
41
     *
42
     * @return string
43
     */
44
    public function getTableClass($tableName)
45
    {
46
        if (false === array_key_exists($tableName, $this->tableNameMap)) {
47
            return UnknownTable::class;
48
        }
49
50
        return $this->tableNameMap[$tableName];
51
    }
52
}