Completed
Push — master ( 4cf390...186a7f )
by Gabriel
02:55
created

Manager::getConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
        return $data;
28
    }
29
30
    /**
31
     * @return Cache
32
     */
33
    public function getCache()
34
    {
35
        if (!$this->_cache) {
36
            $this->_cache = new Cache();
37
            $this->_cache->setMetadata($this);
38
        }
39
40
        return $this->_cache;
41
    }
42
}
43