Completed
Push — master ( 5df59f...c0d6d9 )
by James Ekow Abaka
02:05
created

DriverFactory::createDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 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 27
    public function __construct(array $config)
17
    {
18 27
        $this->config = $config;
19 27
    }
20
21
    /**
22
     * Create a new driver based on the configuration in the factory.
23
     * 
24
     * @return \ntentan\atiaa\Driver
25
     */
26 27
    public function createDriver() : Driver
27
    {
28 27
        $classname = '\ntentan\atiaa\drivers\\' . Text::ucamelize($this->config['driver']) . "Driver";
29 27
        return new $classname($this->config);
30
    }
31
}