Drivers::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Pattern for basic functionality of drivers
5
 *
6
 * PHP Version 5
7
 *
8
 * @category  Core
9
 * @package   Service
10
 * @author    Hans-Joachim Piepereit <[email protected]>
11
 * @copyright 2013 cSphere Team
12
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
13
 * @link      http://www.csphere.eu
14
 **/
15
16
namespace csphere\core\service;
17
18
/**
19
 * Pattern for basic functionality of drivers
20
 *
21
 * @category  Core
22
 * @package   Service
23
 * @author    Hans-Joachim Piepereit <[email protected]>
24
 * @copyright 2013 cSphere Team
25
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
26
 * @link      http://www.csphere.eu
27
 **/
28
29
abstract class Drivers
30
{
31
    /**
32
     * Stores the loader object
33
     **/
34
    protected $loader = null;
35
36
    /**
37
     * Stores the driver configuration
38
     **/
39
    protected $config = [];
40
41
    /**
42
     * Creates the driver handler object
43
     *
44
     * @param array $config Configuration details as an array
45
     *
46
     * @return \csphere\core\service\Drivers
47
     **/
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
48
49
    public function __construct(array $config)
50
    {
51
        // Store loader object
52
        $this->loader = \csphere\core\service\Locator::get();
53
54
        // Check for empty driver
55
        if (empty($config['driver'])) {
56
57
            $config['driver'] = 'none';
58
        }
59
60
        $this->config = $config;
61
    }
62
63
    /**
64
     * Returns the name of the driver
65
     *
66
     * @return string
67
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
68
69
    public function driver()
70
    {
71
        return $this->config['driver'];
72
    }
73
}
74