email = $email; $this->name = $name; } /** * @return string */ public function getEmail():string { return $this->email; } /** * @return string */ public function getName():string { if ($this->name !== null) { return $this->name; } return ''; } /** * @param string $name */ public function setName($name):void { $this->name = $name; } /** * @return string */ public function __toString():string { if ($this->name === null) { return $this->email; } return sprintf('%s<%s>', $this->name, $this->email); } /** * @return array */ public function jsonSerialize(): array { return ['email' => $this->email, 'name' => $this->name]; } }