4
4
5
5
class DefaultCredentialsProvider implements CredentialsProvider {
6
6
7
- private $ username ;
8
- private $ password ;
7
+ private $ credentials ;
9
8
10
- public function __construct ($ username , $ password ) {
11
- $ this ->username = $ username ;
12
- $ this ->password = $ password ;
9
+ public function __construct ($ username , $ password ) {
10
+ $ this ->credentials = array (
11
+ 'username ' => $ username ,
12
+ 'password ' => $ password
13
+ );
13
14
}
14
15
15
16
/**
16
17
* Returns the username.
17
18
* @return string the username
18
19
*/
19
20
public function getUsername (){
20
- return $ this ->username ;
21
+ return $ this ->get ( ' username ' ) ;
21
22
}
22
23
23
24
/**
24
25
* Returns the password.
25
26
* @return string the password
26
27
*/
27
28
public function getPassword () {
28
- return $ this ->password ;
29
+ return $ this ->get ( ' password ' ) ;
29
30
}
30
-
31
- }
31
+
32
+ /**
33
+ * Returns the credentials of the given key.
34
+ * @param string $key - the key of the credentials.
35
+ * @return string the credentials stored of NULL
36
+ */
37
+ public function get ($ key ) {
38
+ if (isset ($ this ->credentials [$ key ])) {
39
+ return $ this ->credentials [$ key ];
40
+ }
41
+ return NULL ;
42
+ }
43
+
44
+ /**
45
+ * Sets the credentials of the given key.
46
+ * @param string $key - the key of the credentials.
47
+ * @param string $value - credentials to be stored at this key
48
+ */
49
+ protected function set ($ key , $ value ) {
50
+ $ this ->credentials [$ key ] = $ value ;
51
+ }
52
+ }
0 commit comments