/**
  * @param IElection         $election
  * @param IFoundationMember $voter
  * @return IVote
  */
 public function buildVote(IElection $election, IFoundationMember $voter)
 {
     $vote = new Vote();
     $vote->ElectionID = $election->getIdentifier();
     $vote->VoterID = $voter->getIdentifier();
     return $vote;
 }
 /**
  * @param IFoundationMember $foundation_member
  * @param IElection         $last_election
  * @return IFoundationMemberRevocationNotification
  */
 public function build(IFoundationMember $foundation_member, IElection $last_election)
 {
     $notification = new FoundationMemberRevocationNotification();
     $notification->RecipientID = $foundation_member->getIdentifier();
     $notification->LastElectionID = $last_election->getIdentifier();
     return $notification;
 }
 /**
  * @param IFoundationMember   $member
  * @param int                 $latest_elections_qty
  * @param int                 $necessary_votes
  * @param IElectionRepository $elections_repository
  * @param IVoteRepository     $vote_repository
  * @return bool
  */
 public function mustSendNotification(IFoundationMember $member, $latest_elections_qty, $necessary_votes, IElectionRepository $elections_repository, IVoteRepository $vote_repository)
 {
     // must be a foundation member, otherwise, do not sent anything
     if (!$member->isFoundationMember()) {
         return false;
     }
     $elections = $elections_repository->getLatestNElections($latest_elections_qty);
     if (count($elections) == 0) {
         return false;
     }
     $elections_id = array();
     $latest_election = $elections[0];
     $latest_election_id = $latest_election->getIdentifier();
     foreach ($elections as $election) {
         array_push($elections_id, $election->getIdentifier());
     }
     // must not have pending revocation notifications , otherwise, do not sent anything
     if ($member->hasPendingRevocationNotifications($latest_election_id)) {
         return false;
     }
     return $vote_repository->getVotesCountByMemberAndElections($member->getIdentifier(), $elections_id) < $necessary_votes;
 }