PDOFactory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 87
c 0
b 0
f 0
ccs 22
cts 22
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createPDO() 0 4 1
A getDsn() 0 4 1
A getUser() 0 4 1
A getPassword() 0 4 1
A setDsn() 0 4 1
A setUser() 0 4 1
A setPassword() 0 4 1
1
<?php
2
3
namespace TonicHealthCheck\Check\DB;
4
5
use PDO;
6
7
/**
8
 * Class PDOFactory.
9
 */
10
class PDOFactory implements PDOFactoryInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $dsn;
16
17
    /**
18
     * @var string
19
     */
20
    protected $user;
21
22
    /**
23
     * @var string
24
     */
25
    protected $password;
26
27
    /**
28
     * PDOFactoryInterface constructor.
29
     *
30
     * @param string $dsn
31
     * @param string $user
32
     * @param string $password
33
     */
34 7
    public function __construct($dsn, $user, $password)
35
    {
36 7
        $this->setDsn($dsn);
37 7
        $this->setUser($user);
38 7
        $this->setPassword($password);
39 7
    }
40
41
    /**
42
     * @return PDO
43
     */
44 4
    public function createPDO()
45
    {
46 4
        return new PDO($this->getDsn(), $this->getUser(), $this->getPassword());
47
    }
48
49
    /**
50
     * @return string
51
     */
52 4
    public function getDsn()
53
    {
54 4
        return $this->dsn;
55
    }
56
57
    /**
58
     * @return string
59
     */
60 4
    public function getUser()
61
    {
62 4
        return $this->user;
63
    }
64
65
    /**
66
     * @return string
67
     */
68 4
    public function getPassword()
69
    {
70 4
        return $this->password;
71
    }
72
73
    /**
74
     * @param string $dsn
75
     */
76 7
    protected function setDsn($dsn)
77
    {
78 7
        $this->dsn = $dsn;
79 7
    }
80
81
    /**
82
     * @param string $user
83
     */
84 7
    protected function setUser($user)
85
    {
86 7
        $this->user = $user;
87 7
    }
88
89
    /**
90
     * @param string $password
91
     */
92 7
    protected function setPassword($password)
93
    {
94 7
        $this->password = $password;
95 7
    }
96
}
97