-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUser.php
More file actions
64 lines (54 loc) · 1.01 KB
/
Copy pathUser.php
File metadata and controls
64 lines (54 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
class User {
/**
* @var string
*/
private $_username;
/**
* @var string
*/
private $_password;
/**
* @param string|array $data
*/
public function __construct($data) {
if (is_array($data)) {
$this->setUsername($data['username']);
$this->setPassword($data['password']);
} else {
list($this->_username, $this->_password) = explode(":", $data);
}
}
/**
* @return string
*/
public function getUsername() {
return $this->_username;
}
/**
* @param string $value
*/
private function setUsername($value) {
$this->_username = $value;
}
/**
* @return string
*/
public function getPassword() {
return $this->_password;
}
/**
* @param $password
*/
public function setPassword($password) {
if (empty($password))
throw new Exception("Ein leeres Passwort ist nicht erlaubt.");
$this->_password = crypt($password, base64_encode($password));
}
/**
* @return string
*/
public function __toString() {
return $this->_username . ":" . $this->_password;
}
}