Manager::describeTable()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Nip\Database\Metadata;
4
5
use Nip\Database\Connections\HasConnectionTrait;
6
7
/**
8
 * Class Manager
9
 * @package Nip\Database\Metadata
10
 */
11
class Manager
12
{
13
    use HasConnectionTrait;
14
15
    protected $_cache;
16
17
    /**
18
     * @param $table
19
     * @return bool|mixed
20
     */
21
    public function describeTable($table)
22
    {
23
        $data = $this->getCache()->describeTable($table);
24
        if (!is_array($data)) {
25
            return trigger_error("Cannot load metadata for table [$table]", E_USER_ERROR);
26
        }
27
28
        return $data;
29
    }
30
31
    /**
32
     * @return Cache
33
     */
34
    public function getCache()
35
    {
36
        if (!$this->_cache) {
37
            $this->_cache = new Cache();
38
            $this->_cache->setMetadata($this);
39
        }
40
41
        return $this->_cache;
42
    }
43
}
44