/** * @param int $optInId * @param Contact $contact * * @return OptIn */ public function hasOptInEnabledByContact($optInId, Contact $contact) { /* * The OptIn is a n:m entity, so we just check if the contact has the optIn */ foreach ($contact->getOptIn() as $optIn) { if ($optIn->getId() === $optInId) { return true; } } return false; }