repository = $repository; } /** * @param UserInvitationObject $object * @return bool * @throws ResourceConflictException */ public function execute(UserInvitationObject $object){ // ensure that there is not already an invitation for the email $existingInvitations = $this->repository->where('email', $object->getInviteeEmail())->first(); if ($existingInvitations) { throw new ResourceConflictException("An existing invitation already exists for the email {$object->getInviteeEmail()}"); } return true; } }