src/STV/ElectionRunner.php
protected function checkAllBallotCandidatesValid(array $ranking): bool
    {
        $candidateIds = $this->election->getCandidateIds();

        foreach ($ranking as $candidate) {
            if (!in_array($candidate, $candidateIds)) {
                $this->logger->debug('Invalid ballot - invalid candidate');

                return false;
            }
        }

        return true;
    }
protected function checkAllBallotCandidatesValid(array $ranking): bool
    {
        $candidateIds = $this->election->getCandidateIds();

        foreach ($ranking as $candidate) {
            if (!in_array($candidate, $candidateIds)) {
                $this->logger->debug('Invalid ballot - invalid candidate');

                return false;
            }
        }

        return true;
    }
protected function checkAllBallotCandidatesValid ( array $ ranking ) : bool { $ candidateIds = $ this -> election -> getCandidateIds ( ) ; foreach ( $ ranking as $ candidate ) { if ( ! in_array ( $ candidate , $ candidateIds ) ) { $ this -> logger -> debug ( 'Invalid ballot - invalid candidate' ) ; return false ; } } return true ; }
Check that a ballot only contains candidate id numbers that are integers
and correspond to valid candidates.

@param  array  $ranking Ballot ranking

@return bool   False if invalid, True if valid
Check that a ballot only contains candidate id numbers that are integers and correspond to valid candidates .