AdapterPool   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 48
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A add() 0 5 1
A remove() 0 5 1
A get() 0 4 1
1
<?php
2
3
namespace Silk\Database;
4
5
use Zend\Db\Adapter\Adapter;
6
use Zend\Db\TableGateway\Feature\GlobalAdapterFeature;
7
8
/**
9
 * AdapterPool
10
 *
11
 * @author  Lucas A. de Araújo <[email protected]>
12
 * @package Silk\Database
13
 */
14
class AdapterPool
15
{
16
    /**
17
     * Pool of adapters
18
     *
19
     * @var array
20
     */
21
    protected static $pool = [];
22
23
    /**
24
     * Construtor
25
     */
26
    public function __construct()
27
    {
28
        // Conexão com o MySQL
29
        $this->add('Default', GlobalAdapterFeature::getStaticAdapter());
30
    }
31
    
32
    /**
33
     * @param $key
34
     * @param Adapter $adapter
35
     * @return $this
36
     */
37
    public function add($key, Adapter $adapter)
38
    {
39
        self::$pool[$key] = $adapter;
40
        return $this;
41
    }
42
43
    /**
44
     * @param $key
45
     * @return $this
46
     */
47
    public function remove($key)
48
    {
49
        unset(self::$pool[$key]);
50
        return $this;
51
    }
52
53
    /**
54
     * @param $key
55
     * @return Adapter
56
     */
57
    public function get($key)
58
    {
59
        return self::$pool[$key];
60
    }
61
}
62