AbstractInjector   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 48
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getDbResource() 0 4 1
1
<?php
2
3
/**
4
 * AppserverIo\Server\Configuration\Extension\AbstractInjector
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Bernhard Wick <[email protected]>
15
 * @copyright 2015 TechDivision GmbH - <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://www.github.com/appserver-io/server
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Server\Configuration\Extension;
22
23
/**
24
 * This class allows to inject a configuration based in a database
25
 *
26
 * @author    Bernhard Wick <[email protected]>
27
 * @copyright 2015 TechDivision GmbH - <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://www.github.com/appserver-io/server
30
 * @link      http://www.appserver.io
31
 */
32
abstract class AbstractInjector implements InjectorInterface
33
{
34
35
    /**
36
     * The PDO database connection object
37
     *
38
     * @var \PDO $dbResource
39
     */
40
    protected $pdoString;
41
42
    /**
43
     * The PDO database connection object
44
     *
45
     * @var \PDO $dbResource
46
     */
47
    protected $user;
48
49
    /**
50
     * The PDO database connection object
51
     *
52
     * @var \PDO $dbResource
53
     */
54
    protected $password;
55
56
    /**
57
     * Default constructor
58
     *
59
     * @param string $pdoString The PDO connection string
60
     * @param string $user      The user used to connect to the DB
61
     * @param string $password  The needed password
62
     */
63
    public function __construct($pdoString, $user = '', $password = '')
64
    {
65
        $this->pdoString = $pdoString;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pdoString of type string is incompatible with the declared type object<PDO> of property $pdoString.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
66
        $this->user = $user;
0 ignored issues
show
Documentation Bug introduced by
It seems like $user of type string is incompatible with the declared type object<PDO> of property $user.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
67
        $this->password = $password;
0 ignored issues
show
Documentation Bug introduced by
It seems like $password of type string is incompatible with the declared type object<PDO> of property $password.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
68
    }
69
70
    /**
71
     * Getter for the database resource
72
     *
73
     * @return \PDO
74
     */
75
    public function getDbResource()
76
    {
77
        return new \PDO($this->pdoString, $this->user, $this->password);
78
    }
79
}
80