Completed
Push — master ( 5fab54...da6320 )
by Derek Stephen
09:42
created

DbCredentials::setUser()   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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
4
namespace Del\Common;
5
6
7
class DbCredentials
8
{
9
    /** @var  array */
10
    private $credentials;
11
    
12 6
    public function __construct(array $array = null)
13
    {
14 6
        $this->credentials = [];
15 6
        $this->credentials['driver'] = $array['driver'] ?: 'pdo_mysql';
16 6
        $this->credentials['dbname'] = $array['dbname'] ?: 'delboy1978uk';
17 6
        $this->credentials['user'] = $array['user'] ?: 'dbuser';
18 6
        $this->credentials['password'] = $array['password'] ?: '[123456]';
19 6
    }
20
21
    /**
22
     * @return string
23
     */
24 1
    public function getPassword()
25
    {
26 1
        return $this->credentials['password'];
27
    }
28
29
    /**
30
     * @param string $password
31
     * @return DbCredentials
32
     */
33 1
    public function setPassword($password)
34
    {
35 1
        $this->credentials['password'] = $password;
36 1
        return $this;
37
    }
38
39
    /**
40
     * @return string
41
     */
42 1
    public function getUser()
43
    {
44 1
        return $this->credentials['user'];
45
    }
46
47
    /**
48
     * @param string $user
49
     * @return DbCredentials
50
     */
51 2
    public function setUser($user)
52
    {
53 2
        $this->credentials['user'] = $user;
54 2
        return $this;
55
    }
56
57
    /**
58
     * @return string
59
     */
60 1
    public function getDatabase()
61
    {
62 1
        return $this->credentials['database'];
63
    }
64
65
    /**
66
     * @param string $database
67
     * @return DbCredentials
68
     */
69 1
    public function setDatabase($database)
70
    {
71 1
        $this->credentials['database'] = $database;
72 1
        return $this;
73
    }
74
75
    /**
76
     * @return string
77
     */
78 1
    public function getDriver()
79
    {
80 1
        return $this->credentials['driver'];
81
    }
82
83
    /**
84
     * @param string $driver
85
     * @return DbCredentials
86
     */
87 1
    public function setDriver($driver)
88
    {
89 1
        $this->credentials['driver'] = $driver;
90 1
        return $this;
91
    }
92
93
    /**
94
     * @return array
95
     */
96 5
    public function toArray()
97
    {
98 5
        return $this->credentials;
99
    }
100
}