Completed
Push — dev ( 3dc717...d8cd31 )
by James Ekow Abaka
03:06 queued 10s
created

DriverFactory::getConfig()   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 1
crap 2
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
    /**
22
     * Set or replace the configuration found in the factory.
23
     * 
24
     * @param $config
25
     */
26
    public function setConfig($config) : void
27
    {
28
        $this->config = $config;
29
    }
30
31
    /**
32
     * Return the configuration currently stored in the factory.
33
     *
34
     * @param $config
35
     * @return array
36
     */
37
    public function getConfig($config) : array
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        return $this->config;
40
    }
41
42
    /**
43
     * Create a new driver based on the configuration in the factory.
44
     * 
45
     * @return \ntentan\atiaa\Driver
46
     */
47 33
    public function createDriver() : Driver
48
    {
49 33
        $classname = '\ntentan\atiaa\drivers\\' . Text::ucamelize($this->config['driver']) . "Driver";
50 33
        return new $classname($this->config);
51
    }
52
}