44
55class DefaultCredentialsProvider implements CredentialsProvider {
66
7- private $ username ;
8- private $ password ;
7+ private $ credentials ;
98
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+ );
1314 }
1415
1516 /**
1617 * Returns the username.
1718 * @return string the username
1819 */
1920 public function getUsername (){
20- return $ this ->username ;
21+ return $ this ->get ( ' username ' ) ;
2122 }
2223
2324 /**
2425 * Returns the password.
2526 * @return string the password
2627 */
2728 public function getPassword () {
28- return $ this ->password ;
29+ return $ this ->get ( ' password ' ) ;
2930 }
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