original_string: protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate)
      {
          if (!in_array($currencyTo, $this->managedCurrencies)) {
              return false;
          }
          
          $exchangeRate = $this->currencyRateRepository->findOneBy([
              'currencyFrom' => $currencyFrom,
              'currencyTo'   => $currencyTo,
          ]);
          
          if (null === $exchangeRate) {
              $exchangeRate = new CurrencyRate();
              $exchangeRate->setCurrencyFrom($currencyFrom);
              $exchangeRate->setCurrencyTo($currencyTo);
              $exchangeRate->setExchangeRate($rate);
              $this->helper->getEntityManager()->persist($exchangeRate);
          } else {
              $exchangeRate->setExchangeRate($rate);
          }
          
          return true;
      }
code: protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate)
      {
          if (!in_array($currencyTo, $this->managedCurrencies)) {
              return false;
          }
          
          $exchangeRate = $this->currencyRateRepository->findOneBy([
              'currencyFrom' => $currencyFrom,
              'currencyTo'   => $currencyTo,
          ]);
          
          if (null === $exchangeRate) {
              $exchangeRate = new CurrencyRate();
              $exchangeRate->setCurrencyFrom($currencyFrom);
              $exchangeRate->setCurrencyTo($currencyTo);
              $exchangeRate->setExchangeRate($rate);
              $this->helper->getEntityManager()->persist($exchangeRate);
          } else {
              $exchangeRate->setExchangeRate($rate);
          }
          
          return true;
      }
code_tokens: protected function addUpdateExchangeRate ( $ currencyFrom , $ currencyTo , $ rate ) { if ( ! in_array ( $ currencyTo , $ this -> managedCurrencies ) ) { return false ; } $ exchangeRate = $ this -> currencyRateRepository -> findOneBy ( [ 'currencyFrom' => $ currencyFrom , 'currencyTo' => $ currencyTo , ] ) ; if ( null === $ exchangeRate ) { $ exchangeRate = new CurrencyRate ( ) ; $ exchangeRate -> setCurrencyFrom ( $ currencyFrom ) ; $ exchangeRate -> setCurrencyTo ( $ currencyTo ) ; $ exchangeRate -> setExchangeRate ( $ rate ) ; $ this -> helper -> getEntityManager ( ) -> persist ( $ exchangeRate ) ; } else { $ exchangeRate -> setExchangeRate ( $ rate ) ; } return true ; }
docstring: Adds new rate or updates existing one
  
  @param string $currencyFrom
  @param string $currencyTo
  @param float  $rate
docstring_tokens: Adds new rate or updates existing one