/**
  * Convert contry string (e.g. United States of America) into 2 or 3 letter (e.g. US or USA)
  * Or country 2 or 3 letters code to country string in English
  * Or betweeen country codes: Values for $nbLetters:
  * 3  : country   -> 3 letters
  * 2  : country   -> 2 letters
  * -2 : 2 letters -> country
  * -3 : 3 letters -> country
  * 23 : 2 letters -> 3 letters
  * 32 : 3 letters -> 2 letters
  *
  * @param  string $country    Full text country name (if $nbLetters = 2 or 3) or country code (if $nbLetters = -2 or -3 or 23 or 32)
  * @param  int    $nbLetters  Number of letters code (2 or 3 for full name to code and -2 or -3 for code to name)
  * @return string             2/3/full-letters country name
  */
 protected function countryToLetters($country, $nbLetters)
 {
     $countries = new cbpaidCountries();
     switch ($nbLetters) {
         case 3:
             $ret = $countries->countryToThreeLetters($country);
             break;
         case 2:
             $ret = $countries->countryToTwoLetters($country);
             break;
         case -2:
             $ret = $countries->twoLettersToCountry($country);
             break;
         case -3:
             $ret = $countries->threeLettersToCountry($country);
             break;
         case 23:
             $ret = $countries->twoToThreeLettersCountry($country);
             break;
         case 32:
             $ret = $countries->threeToTwoLettersCountry($country);
             break;
         default:
             trigger_error('Unknown nbLetters in countryToLetters', E_USER_WARNING);
             $ret = null;
             break;
     }
     if ($ret === null) {
         $n = $nbLetters < 0 ? 255 : $nbLetters % 10;
         $ret = substr($country, 0, $n);
     }
     return $ret;
 }