/**
* User
*/
-class User implements UserInterface, PasswordAuthenticatedUserInterface, \Serializable {
+class User implements UserInterface, PasswordAuthenticatedUserInterface {
/**
* @var integer
*/
/**
* Constructor
*
- * @param string $mail The user mail
+ * @param ?string $mail The user mail
*/
- public function __construct(string $mail) {
+ public function __construct(?string $mail) {
//With mail
- if (!empty($this->mail = $mail)) {
+ if ($mail !== null && !empty($mail)) {
+ $this->mail = $mail;
$this->password = $mail;
+ //Without mail
} else {
+ $this->mail = '';
$this->password = '';
}
/**
* Set mail
*
- * @param string $mail
- *
+ * @param ?string $mail
* @return User
*/
- public function setMail(string $mail): User {
+ public function setMail(?string $mail): User {
//With mail
- if (!empty($this->mail = $mail)) {
+ if ($mail !== null && !empty($mail)) {
+ //Set mail
+ $this->mail = $mail;
+
//Without password
if (empty($this->password)) {
//Set mail as password
$this->password = $mail;
}
+ //Without mail
+ } else {
+ $this->mail = '';
}
return $this;
*
* @return User
*/
- public function setPassword(string $password): User {
- $this->password = $password;
+ public function setPassword(?string $password): User {
+ //With password
+ if ($password !== null && !empty($password)) {
+ $this->password = $password;
+ //Without password
+ } else {
+ $this->password = '';
+ }
return $this;
}
*
* @return string
*/
- public function getPassword(): ?string {
+ public function getPassword(): string {
return $this->password;
}
/**
* {@inheritdoc}
*/
- public function serialize(): string {
- return serialize([
+ public function __serialize(): array {
+ return [
$this->id,
$this->mail,
$this->forename,
$this->disabled,
$this->created,
$this->updated
- ]);
+ ];
}
/**
* {@inheritdoc}
*/
- public function unserialize($serialized) {
+ public function __unserialize(array $data): void {
list(
$this->id,
$this->mail,
$this->disabled,
$this->created,
$this->updated
- ) = unserialize($serialized);
+ ) = $data;
}
/**