Completed
Push — master ( 32abd3...17d81c )
by Beniamin
02:41
created

ConnectionManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerConnection() 0 4 1
A getConnection() 0 4 2
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\SQLBuilder\Connection;
13
14
/**
15
 * @author Beniamin Jonatan Šimko <[email protected]>
16
 */
17
class ConnectionManager implements ConnectionManagerInterface
18
{
19
    /**
20
     * @var array
21
     */
22
    private $connections = [];
23
24
    /**
25
     * @inheritdoc
26
     */
27 2
    public function registerConnection(ConnectionInterface $connection, $name = 'default')
28
    {
29 2
        $this->connections[$name] = $connection;
30 2
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35 2
    public function getConnection($name = null)
36
    {
37 2
        return $name ? $this->connections[$name] : reset($this->connections);
38
    }
39
}