original_string: public function getPreviousRoundId($roundId, $roundOrder = null)
      {
         $this->_ensureRounds();
  
         if ($this->_rounds && $roundId) {
             $returnId = null;
             foreach ($this->_rounds as $currentRoundId => $round) {
                 if (($currentRoundId == $roundId) || ($roundOrder && ($round['gro_id_order'] >= $roundOrder))) {
                     // Null is returned when querying this function with the first round id.
                     return $returnId;
                 }
                 $returnId = $currentRoundId;
             }
  
  
             throw new \Gems_Exception_Coding("Requested non existing previous round id for round $roundId.");
  
         } elseif ($this->_rounds) {
              end($this->_rounds);
              $key = key($this->_rounds);
              if (empty($key) && !is_null($key)) {
                  // The last round (with empty index) is the current round, step back one more round
                  prev($this->_rounds);
              }
              return key($this->_rounds);
          }
      }
code: public function getPreviousRoundId($roundId, $roundOrder = null)
      {
         $this->_ensureRounds();
  
         if ($this->_rounds && $roundId) {
             $returnId = null;
             foreach ($this->_rounds as $currentRoundId => $round) {
                 if (($currentRoundId == $roundId) || ($roundOrder && ($round['gro_id_order'] >= $roundOrder))) {
                     // Null is returned when querying this function with the first round id.
                     return $returnId;
                 }
                 $returnId = $currentRoundId;
             }
  
  
             throw new \Gems_Exception_Coding("Requested non existing previous round id for round $roundId.");
  
         } elseif ($this->_rounds) {
              end($this->_rounds);
              $key = key($this->_rounds);
              if (empty($key) && !is_null($key)) {
                  // The last round (with empty index) is the current round, step back one more round
                  prev($this->_rounds);
              }
              return key($this->_rounds);
          }
      }
code_tokens: public function getPreviousRoundId ( $ roundId , $ roundOrder = null ) { $ this -> _ensureRounds ( ) ; if ( $ this -> _rounds && $ roundId ) { $ returnId = null ; foreach ( $ this -> _rounds as $ currentRoundId => $ round ) { if ( ( $ currentRoundId == $ roundId ) || ( $ roundOrder && ( $ round [ 'gro_id_order' ] >= $ roundOrder ) ) ) { // Null is returned when querying this function with the first round id. return $ returnId ; } $ returnId = $ currentRoundId ; } throw new \ Gems_Exception_Coding ( "Requested non existing previous round id for round $roundId." ) ; } elseif ( $ this -> _rounds ) { end ( $ this -> _rounds ) ; $ key = key ( $ this -> _rounds ) ; if ( empty ( $ key ) && ! is_null ( $ key ) ) { // The last round (with empty index) is the current round, step back one more round prev ( $ this -> _rounds ) ; } return key ( $ this -> _rounds ) ; } }
docstring: Look up the round id for the previous round
  
  @param int $roundId  Gems round id
  @param int $roundOrder Optional extra round order, for when the current round may have changed.
  @return int Gems round id
docstring_tokens: Look up the round id for the previous round