Exemplo n.º 1
0
 public function getResult($method = true, array $options = []) : Result
 {
     $options = $this->formatResultOptions($options);
     // Filter if tag is provided & return
     if ($options['%tagFilter']) {
         $chrono = new Timer_Chrono($this->_timer, 'GetResult with filter');
         $filter = new self();
         foreach ($this->getCandidatesList() as $candidate) {
             $filter->addCandidate($candidate);
         }
         foreach ($this->getVotesList($options['tags'], $options['withTag']) as $vote) {
             $filter->addVote($vote);
         }
         unset($chrono);
         return $filter->getResult($method, ['algoOptions' => $options['algoOptions']]);
     }
     ////// Start //////
     // Prepare
     $this->prepareResult();
     //////
     $chrono = new Timer_Chrono($this->_timer);
     if ($method === true) {
         $this->initResult(Condorcet::getDefaultMethod());
         $result = $this->_Calculator[Condorcet::getDefaultMethod()]->getResult($options['algoOptions']);
     } elseif ($method = Condorcet::isAuthMethod($method)) {
         $this->initResult($method);
         $result = $this->_Calculator[$method]->getResult($options['algoOptions']);
     } else {
         throw new CondorcetException(8, $method);
     }
     $chrono->setRole('GetResult for ' . $method);
     return $result;
 }
Exemplo n.º 2
0
 public function startDeclare(Chrono $chrono)
 {
     if ($this->_startDeclare === null) {
         $this->_startDeclare = $chrono->getStart();
     }
 }