Completed
Push — master ( 8a572d...d7738d )
by James Ekow Abaka
01:18
created

DriverFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 30
ccs 6
cts 9
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setConfig() 0 4 1
A createDriver() 0 5 1
1
<?php
2
3
namespace ntentan\atiaa;
4
5
use ntentan\utils\Text;
6
7
class DriverFactory
8
{
9
    private $config;
10
11
    /**
12
     * Create an instance of the driver factory with the connection configurations.
13
     * 
14
     * @param array $config
15
     */
16 33
    public function __construct(array $config = null)
17
    {
18 33
        $this->config = $config;
19 33
    }
20
    
21
    public function setConfig($config) : void
22
    {
23
        $this->config = $config;
24
    }
25
26
    /**
27
     * Create a new driver based on the configuration in the factory.
28
     * 
29
     * @return \ntentan\atiaa\Driver
30
     */
31 33
    public function createDriver() : Driver
32
    {
33 33
        $classname = '\ntentan\atiaa\drivers\\' . Text::ucamelize($this->config['driver']) . "Driver";
34 33
        return new $classname($this->config);
35
    }
36
}