+ public function setMail(string $mail): User {
+ //With mail
+ if (!empty($this->mail = $mail)) {
+ //Without forename and surname
+ if (empty($this->forename) && empty($this->surname)) {
+ //Extract names from mail
+ $names = explode(' ', ucwords(trim(preg_replace('/[^a-zA-Z]+/', ' ', current(explode('@', $mail))))));
+ //Set forename
+ $this->forename = $names[0];
+ //Set surname
+ $this->surname = $names[1]??$names[0];
+ }
+ }