/** * @param IdentityInterface|string $to */ public function __construct($to) { $email = $to instanceof IdentityInterface ? $to->getEmail() : $to; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('Invalid email'); } $this->to = $to; }