/** * @param EmailModel $model * * @throws \InvalidArgumentException */ protected function assertModel(EmailModel $model) { if (!$model->getFrom()) { throw new \InvalidArgumentException('Sender can not be empty'); } if (!$model->getTo() && !$model->getCc() && !$model->getBcc()) { throw new \InvalidArgumentException('Recipient can not be empty'); } }
/** * @param Email $value * @param Constraint|EmailRecipients $constraint */ public function validate($value, Constraint $constraint) { if (!$value->getTo() && !$value->getCc() && !$value->getBcc()) { $this->context->addViolation($constraint->message); } }