Exemplo n.º 1
0
 public function __construct($sEncoding)
 {
     if (!is_string($sEncoding)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_HANDLER);
     }
     $bValidEncoding = Encoding::isValidEncoding($sEncoding);
     if (!$bValidEncoding) {
         throw ExceptionType::domain("L'encodage passé en paramètre ({$sEncoding}) n'est pas valide. Il doit correspondre à l'un des encodages suivants : " . implode(', ', mb_list_encodings()), Exception::FROM_HANDLER);
     }
     $this->_sFinalEncoding = $bValidEncoding;
 }
Exemplo n.º 2
0
 /**
  * Returns a word in singular form.
  *
  * @param string $sWord The word in plural form.
  *
  * @return string The word in singular form.
  */
 public function singularize($sWord, $sEncoding = null)
 {
     if ($sEncoding === null) {
         $sEncoding = Encoding::detectEncoding($sWord);
     } else {
         $sEncoding = Encoding::isValidEncoding($sEncoding);
         if (!$sEncoding) {
             throw ExceptionType::domain("Argument #2 n'est pas un encodage valide.", Exception::FROM_INFLECTOR);
         }
     }
     $sResult = $this->_process($sWord, $sEncoding, $this->_oLocale->singulars());
     return $this->_aCache['singular'][$sWord] = $sResult ?: $sWord;
 }
Exemplo n.º 3
0
 /**
  * Convertit la chaîne de caractères dans l'encodage renseigné ou bien retourne le type d'encodage utilisé.
  * Attention : la modification de l'encodage n'est pas fiable à 100%.
  * 
  * @todo gerer exception
  * @param string $sEncodeTo Si ce paramètre est absent, la méthode retourne le type d'encodage courant. Dans l'autre cas, il convertit la chaîne dans l'encodage renseigné.
  * @return Encoding
  * @throws Exception
  */
 public function __construct($sEncodeTo)
 {
     // S'il y a des segments en cours de traitement
     $iProcessingPointsNb = Point::processingPointsCount();
     if ($iProcessingPointsNb) {
         throw ExceptionType::runtime("Il n'est pas possible de convertir la sous-chaîne de caractères pointée par la méthode Aouka\\Text\\Manipulator::Point(). Il faut d'abord sortir de toutes les sous-chaînes (qui sont au nombre de {$iProcessingPointsNb}) via la méthode Aouka\\Text\\Manipulator::EndFocus()", Exception::FROM_HANDLER);
     }
     if (!is_string($sEncodeTo)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères ou NULL.", Exception::FROM_HANDLER);
     }
     $sEncodingDestination = Encoding::isValidEncoding($sEncodeTo);
     if (!$sEncodingDestination) {
         throw ExceptionType::domain("Argument #1 n'est pas un encodage valide. Les encodages supportés sont décrits sur http://www.php.net/manual/fr/function.mb-list-encodings.php.", Exception::FROM_HANDLER);
     }
     $this->_sEncodingDestination = $sEncodingDestination;
 }