Exemple #1
0
 public function __construct($fnCallback)
 {
     if (!is_callable($fnCallback)) {
         throw ExceptionType::badFunctionCall("Argument #1 : {$fnCallback} n'est pas une fonction qui peut être appelée.", Exception::FROM_HANDLER);
     }
     $this->_fnCallback = $fnCallback;
 }
 /**
  * Retourne le traducteur.
  * 
  * @return Aouka\Text\Interpretor\InterfaceInterpretor
  * @throws \Exception
  */
 protected function _getInterpretor()
 {
     if (!isset(self::$_aInterpretors[$this->_sManipulatorId])) {
         throw ExceptionType::badMethodCall("Aucun traducteur n'a été défini via la méthode Aouka\\Text\\Manipulator::setInterpretor().", Exception::FROM_SUB_HANDLER);
     }
     return self::$_aInterpretors[$this->_sManipulatorId];
 }
 public function __construct($sAllowableTags = '')
 {
     if (!is_string($sAllowableTags)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_HANDLER);
     }
     $this->_sAllowableTags = $sAllowableTags;
 }
Exemple #4
0
 /**
  * Convertit une chaîne de caractères en tableau.
  * 
  * @param integer $iSplitLength Longueur maximale de chaque élément.
  * @throws Aouka\Text\Exception\LogicException\InvalidArgumentException
  */
 public function __construct($iSplitLength = 1)
 {
     if (!is_int($iSplitLength)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un entier.", Exception::FROM_HANDLER);
     }
     $this->_iLength = $iSplitLength;
 }
 public function __construct($aAttributes = array(), $aQuery = array())
 {
     if (!is_array($aAttributes)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un tableau.", Exception::FROM_HANDLER);
     }
     $this->_oAutoLink = new AutoLink(AutoLink::LINK_EMAIL, $aAttributes, $aQuery);
 }
Exemple #6
0
 public function setGender($cGender)
 {
     if (!in_array($cGender, array(self::MALE, self::FEMALE, self::ANY))) {
         throw ExceptionType::domain("Argument #1 doit être égal à l'une des valeurs suivantes : Aouka\\Text\\Generator::MALE, Aouka\\Text\\Generator::FEMALE, Aouka\\Text\\Generator::ANY.", Exception::FROM_GENERATOR);
     }
     $this->_cGender = $cGender;
 }
Exemple #7
0
 public function __construct($iPos)
 {
     if (!is_int($iPos)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un entier.", Exception::FROM_HANDLER);
     }
     $this->_iPos = abs($iPos);
 }
 public function __construct($mToMode)
 {
     if (!in_array($mToMode, array(String::GLOBAL_PARSING, String::CHUNK_PARSING))) {
         throw ExceptionType::domain("Argument #1 doit être égal à Aouka\\Text\\String::GLOBAL_PARSING (" . String::GLOBAL_PARSING . ") ou Aouka\\Text\\String::CHUNK_PARSING (" . String::CHUNK_PARSING . ") ", Exception::FROM_HANDLER);
     }
     $this->_cToMode = $mToMode;
 }
 public function __construct($aAttributes = array(), $aUrl = array())
 {
     if (!is_array($aAttributes)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un tableau.", Exception::FROM_HANDLER);
     }
     if (!is_array($aUrl)) {
         throw ExceptionType::invalidArgument("Argument #2 doit être un tableau.", Exception::FROM_HANDLER);
     } elseif (isset($aUrl[AutoLink::QUERY])) {
         if (!is_array($aUrl[AutoLink::QUERY])) {
             throw ExceptionType::invalidArgument("Argument #2 : l'élément [" . AutoLink::QUERY . "] doit être un tableau.", Exception::FROM_HANDLER);
         }
         if (isset($aUrl[AutoLink::QUERY][AutoLink::QUERY_DATA]) && !is_array($aUrl[AutoLink::QUERY][AutoLink::QUERY_DATA])) {
             throw ExceptionType::invalidArgument("Argument #2 : l'élément [" . AutoLink::QUERY . "][" . AutoLink::QUERY_DATA . "] doit être un tableau.", Exception::FROM_HANDLER);
         }
         if (isset($aUrl[AutoLink::QUERY][AutoLink::QUERY_NUMERIC_PREFIX]) && !is_string($aUrl[AutoLink::QUERY][AutoLink::QUERY_NUMERIC_PREFIX])) {
             throw ExceptionType::invalidArgument("Argument #2 : l'élément [" . AutoLink::QUERY . "][" . AutoLink::QUERY_NUMERIC_PREFIX . "] doit être une chaîne de caractères.", Exception::FROM_HANDLER);
         }
         if (isset($aUrl[AutoLink::QUERY][AutoLink::QUERY_ARG_SEPARATOR]) && !is_string($aUrl[AutoLink::QUERY][AutoLink::QUERY_ARG_SEPARATOR])) {
             throw ExceptionType::invalidArgument("Argument #2 : l'élément [" . AutoLink::QUERY . "][" . AutoLink::QUERY_ARG_SEPARATOR . "] doit être une chaîne de caractères.", Exception::FROM_HANDLER);
         }
         if (isset($aUrl[AutoLink::QUERY][AutoLink::QUERY_ENC_TYPE]) && !in_array($aUrl[AutoLink::QUERY][AutoLink::QUERY_ENC_TYPE], array(PHP_QUERY_RFC1738, PHP_QUERY_RFC3986))) {
             throw ExceptionType::invalidArgument("Argument #2 : l'élément [" . AutoLink::QUERY . "][" . AutoLink::QUERY_ENC_TYPE . "] doit valoir PHP_QUERY_RFC1738 ou PHP_QUERY_RFC3986.", Exception::FROM_HANDLER);
         }
     }
     $this->_oAutoLink = new AutoLink(AutoLink::LINK_URL, $aAttributes, $aUrl);
 }
Exemple #10
0
 /**
  * Cible la partie de la chaîne de caractères commençant à l'occurrence $mStart et terminant à $mEnd.<br/>
  * Toutes les méthodes appelées par la suite ne s'appliqueront que sur la partie du texte qui a été ciblée par cette méthode.
  * Même la méthode \Aouka\Text\Manipulator::get() !<br/>Après avoir ciblé une partie du texte et lui avoir appliqué des transformations,
  * il est possible de revenir à l'intégralité du texte d'origine tout en conservant le résultat des modifications
  * avec la méthode \Aouka\Text\Manipulator::end(). 
  * 
  * <p>
  *	Exemples d'utilisation :<br/>
  *	Ciblage de la partie du texte située :
  *	<ul>
  *		<li>- jusqu'à la fin de la 3ème phrase (incluse) ->focus(NULL, array(3, \Aouka\Text\InterfaceText::SENTENCE).</li>
  *		<li>- avant le début de la 3ème phrase (exclue) ->focus(NULL, array(3, \Aouka\Text\Regex::sentence(), FALSE).</li>
  *		<li>- entre le 15ème mot (exclu) et le dernier mot "toto" (inclus) ->focus(array(15, \Aouka\Text\Regex::word(), FALSE), array(-1, "`(toto)`")).</li>
  *		<li>- après la 3ème lettre "a" (exclue) ->focus(array(3, \Aouka\Text\Regex::create("`(a)`"), FALSE), NULL).</li>
  *	<ul>
  * </p>
  * 
  * @param array|null $mStart Si $mStart vaut NULL, le ciblage commence à partir du début de la chaîne.<br/>
  * Si $mStart est un tableau, il doit contenir entre 2 et 3 éléments : <br/>
  *	<ul>
  *		<li>
  *			- Le premier de ces éléments est un nombre entier qui détermine la position n de l'ancre à partir de
  *			laquelle débute le ciblage. Si ce nombre est positif le ciblage commencera à la énième ancre à partir
  *			du début de la chaîne ; s'il est négatif, le ciblage débutera à la énième ancre à partir de la fin.
  *			S'il vaut 0, l'ancre ne sera pas prise en compte pour le ciblage de début.
  *		</li>
  *		<li>
  *			- Le deuxième de ces éléments est objet \Aouka\Text\Regex, une expression rationnelle ou une constante de l'interface
  *			\Aouka\Text\InterfaceText. Il détermine l'ancre à utiliser.
  *		</li>
  *		<li>
  *			- Le troisième élément est optionnel. Il définit si l'ancre doit être incluse ou exclue du ciblage. Par
  *			défaut, l'ancre est incluse. Il peut être une expression rationnelle sous la forme d'une chaîne de caractères
  *			ou d'un objet \Aouka\Text\Regex. Cela peut aussi être une constante de la classe \Aouka\Text\Interface.
  *		</li>
  *	<ul>
  * @param array|null $mEnd Si $mEnd vaut NULL, le ciblage termine à la fin de la chaîne.<br/>
  * Si $mEnd est un tableau, il doit contenir entre 2 et 3 éléments : <br/>
  *	<ul>
  *		<li>
  *			- Le premier de ces éléments est un nombre entier qui détermine la position n de l'ancre à partir de
  *			laquelle termine le ciblage. Si ce nombre est positif le ciblage terminera à la énième ancre à partir
  *			du début de la chaîne ; s'il est négatif, le ciblage terminera à la énième ancre à partir de la fin.
  *			S'il vaut 0, l'ancre ne sera pas prise en compte pour le ciblage de fin.
  *		</li>
  *		<li>
  *			- Le deuxième de ces éléments est objet \Aouka\Text\Regex, une expression rationnelle ou une constante de l'interface
  *			\Aouka\Text\InterfaceText. Il détermine l'ancre à utiliser.
  *		</li>
  *		<li>
  *			- Le troisième élément est optionnel. Il définit si l'ancre doit être incluse ou exclue du ciblage. Par
  *			défaut, l'ancre est incluse. Il peut être une expression rationnelle sous la forme d'une chaîne de caractères
  *			ou d'un objet \Aouka\Text\Regex. Cela peut aussi être une constante de la classe \Aouka\Text\Interface.
  *		</li>
  *	<ul>	
  */
 public function __construct($mStart, $mEnd = null)
 {
     $aArgs = func_get_args();
     $aArgs[1] = isset($aArgs[1]) ? $aArgs[1] : null;
     for ($i = 0; $i <= 1; $i++) {
         $iArgIndex = $i + 1;
         if (!is_array($aArgs[$i]) && !is_null($aArgs[$i])) {
             throw ExceptionType::invalidArgument("Argument #{$iArgIndex} doit être un tableau ou null.", Exception::FROM_HANDLER);
         }
         if ($aArgs[$i] !== null) {
             $aParams = array_values($aArgs[$i]);
             if (count($aParams) < 2 || !is_int($aParams[0])) {
                 throw ExceptionType::invalidArgument("Argument #{$iArgIndex} n'est pas un tableau indexé ayant comme premier élément un entier positif et second élément une expression rationnelle.\n\t\t\t\t\t\tLe troisième élément est optionnel. C'est un booléen déterminant si l'ancre de focus doit être incluse dans le ciblage.", Exception::FROM_HANDLER);
             }
             try {
                 $aArray = array('regex' => Regex::create($aParams[1]), 'offset' => $aParams[0], 'include' => (bool) (isset($aParams[2]) ? $aParams[2] : self::$_bDefaultInclusion));
             } catch (\Exception $oException) {
                 throw ExceptionType::invalidArgument("Argument #{$iArgIndex} n'a pas comme second élément une expression rationnelle, un objet Aouka\\Text\\Regex ou une constante de Aouka\\Text\\InterfaceText.", Exception::FROM_HANDLER);
             }
             if (!$i) {
                 $this->_aInterval['start'] = $aArray;
             } else {
                 $this->_aInterval['end'] = $aArray;
             }
         }
     }
 }
Exemple #11
0
 /**
  * Remplace $sPattern dans la chaîne de caractères $sRecipient par le texte courant.
  * @param string $sRecipient Chaîne de caractères dans laquelle insérer le texte courant.
  * @param string $sPattern Mot-clé de $sRecipient devant être remplacé par le texte courant.
  * @throws \Exception
  */
 public function __construct($sRecipient, $sPattern)
 {
     if (!is_string($sRecipient) || !is_string($sPattern)) {
         throw ExceptionType::invalidArgument("Arguments #1 et #2 doivent être des chaînes de caractères.");
     }
     $this->_sRecipient = $sRecipient;
     $this->_sPattern = $sPattern;
 }
Exemple #12
0
 public function __construct($sSeparator = PHP_EOL, $bReplacement = false)
 {
     if (!in_array($sSeparator, $this->_getValidSeparators())) {
         throw ExceptionType::invalidArgument("Argument #1 n'est pas un séparateur valide. Il doit faire partie de la liste suivante : " . implode(', ', $this->_getValidSeparators()) . '.', Exception::FROM_HANDLER);
     }
     $this->_sSeparator = $sSeparator;
     $this->_bReplacement = (bool) $bReplacement;
 }
Exemple #13
0
 public function __construct($sCharList = null)
 {
     if ($sCharList !== null) {
         if (!is_string($sCharList)) {
             throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_HANDLER);
         }
     }
     $this->_sCharList = $sCharList;
 }
Exemple #14
0
 protected function _getNestedPropertyValue($sPropertyKeys)
 {
     $aNestedPropertyKeys = explode('.', $sPropertyKeys);
     $mPropertyValue = ArrayHelper::getNestedValue($this->_aProperties, $aNestedPropertyKeys, $bKeyExists);
     if (!$bKeyExists) {
         throw ExceptionType::outOfBounds("La propriété de configuration \"{$sPropertyKeys}\" n'est pas définie.", Exception::FROM_CONFIG);
     }
     return $mPropertyValue;
 }
Exemple #15
0
 protected function _commonHandling()
 {
     try {
         $this->_oString->setLocale($this->_sLocale);
     } catch (\Exception $oException) {
         throw ExceptionType::runtime("Impossible de mettre à jour la locale à cause d'une exception lancée.", Exception::FROM_HANDLER, $oException);
     }
     return $this->_oString;
 }
Exemple #16
0
 public function __construct($sLocale = null)
 {
     //		if (!extension_loaded('intl')) {
     //			throw new \Exception("Cette méthode n'est disponible qu'à condition de charger l'extension PECL intl.");
     //		}
     if (!is_string($sLocale) && $sLocale !== null) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères ou être null.", Exception::FROM_HANDLER);
     }
     $this->_oLocale = $sLocale;
 }
Exemple #17
0
 public function __construct($sDelimiter, $iLimit = null)
 {
     if (!is_string($sDelimiter)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_HANDLER);
     }
     if (!is_null($iLimit) && !is_int($iLimit)) {
         throw ExceptionType::invalidArgument("Argument #2 doit être un entier.", Exception::FROM_HANDLER);
     }
     $this->_sDelimiter = $sDelimiter;
     $this->_iLimit = $iLimit;
 }
Exemple #18
0
 public function __construct($iPadLength, $sPadString = ' ')
 {
     if (!is_int($iPadLength)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un entier.", Exception::FROM_HANDLER);
     }
     if (!is_string($sPadString)) {
         throw ExceptionType::invalidArgument("Argument #2 doit être une chaîne de caractères.", Exception::FROM_HANDLER);
     }
     $this->_iPadLength = $iPadLength;
     $this->_sPadString = $sPadString;
 }
Exemple #19
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;
 }
Exemple #20
0
 public function __construct($aExceptions = array())
 {
     if (!is_array($aExceptions)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un tableau.", Exception::FROM_HANDLER);
     }
     if ($aExceptions) {
         if (array_diff($aExceptions, self::_getCases())) {
             throw ExceptionType::domain("Argument #1 contient une valeur qui n'est pas une constante de casse.", Exception::FROM_HANDLER);
         }
     }
     $this->_aExceptions = $aExceptions;
 }
Exemple #21
0
 /**
  * Limite le nombre de caractères de la chaîne.
  * 
  * @param integer $iMaxLength Nombre maximal de caractères.
  * @param array $aOptions Tableau associatif qui par défaut vaut :<br/>
  * Array(
  *		LimitChars::EXACTLY => false,
  *		LimitChars::MARKER => '...',
  *		LimitChars::INCLUDE_MARKER => true
  * )<br/>
  * où LimitChars::EXACTLY définit si le texte doit exactement respecter la longueur définie $iMaxLength, même dans le cas où la césure survient après des caractères vides;
  * LimitChars::MARKER définit le marker à ajouter après la césure, le cas échéant ;
  * LimitChars::INCLUDE_MARKER définit si les caractères de LimitChars::MARKER doivent être pris en compte par $iMaxLength
  * @throws \Exception
  */
 public function __construct($iMaxLength, $aOptions = array())
 {
     if (!is_int($iMaxLength)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un entier.", Exception::FROM_HANDLER);
     }
     if (!is_array($aOptions)) {
         throw ExceptionType::invalidArgument("Argument #2 doit être un tableau.", Exception::FROM_HANDLER);
     }
     $this->_iMaxLength = $iMaxLength;
     $this->_bExactly = isset($aOptions[self::EXACTLY]) ? (bool) $aOptions[self::EXACTLY] : false;
     $this->_sTrimMarker = isset($aOptions[self::MARKER]) ? (string) $aOptions[self::MARKER] : Config::get('ellipsis');
     $this->_bIncludeTrimMarker = isset($aOptions[self::INCLUDE_MARKER]) ? (bool) $aOptions[self::INCLUDE_MARKER] : true;
 }
Exemple #22
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;
 }
Exemple #23
0
 public function __construct($sType, $sLocale)
 {
     if (!is_string($sType)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_LOCALE);
     }
     if (!Locale::isValid($sLocale)) {
         throw ExceptionType::domain("Argument #2 doit n'est pas une locale valide.", Exception::FROM_LOCALE);
     }
     $sLocaleNamespace = 'Aouka\\Text\\Locale\\' . $sLocale . '\\' . ucfirst(strtolower($sType));
     $oLocaleClass = new \ReflectionClass($sLocaleNamespace);
     $oLocaleInstance = $oLocaleClass->newInstance();
     $this->_oLocaleInstance = $oLocaleInstance;
 }
 public function __construct($bSensitiveCase = true, $bRegroup = false, $aWordRegex = array())
 {
     $this->_bSensitive = (bool) $bSensitiveCase;
     $this->_bRegroup = (bool) $bRegroup;
     if (!is_array($aWordRegex)) {
         throw ExceptionType::invalidArgument("Argument #3 doit être un tableau associatif.", Exception::FROM_HANDLER);
     }
     if (isset($aWordRegex[self::WORD_ADDITIONAL_CHARS])) {
         if (!is_string($aWordRegex[self::WORD_ADDITIONAL_CHARS])) {
             throw ExceptionType::invalidArgument("Argument #3, l'élément " . self::WORD_ADDITIONAL_CHARS . " doit être une chaîne de caractères.", Exception::FROM_HANDLER);
         }
         $this->_sAdditionalChars = $aWordRegex[self::WORD_ADDITIONAL_CHARS];
     }
 }
Exemple #25
0
 /**
  * Définit les tags de début et de fin.
  * 
  * Les tags de fin sont définis à partir des tags de début.
  * 
  * @param string Balises HTML de début.
  * @throws \Exception
  */
 protected function _initTags()
 {
     $oRegexTag = Regex::tag()->setModifiers($this->_m());
     $aTags = array_filter(preg_split("`({$oRegexTag})`", $this->_sInputTags, -1, PREG_SPLIT_DELIM_CAPTURE));
     foreach ($aTags as $sTag) {
         if (!$oRegexTag->test(trim($sTag))) {
             throw ExceptionType::invalidArgument("Argument #1 doit être uniquement composé de balises HTML.", Exception::FROM_HANDLER);
         }
         $this->_sStartingTags = $this->_sInputTags;
         if (preg_match('`^<([[:alnum:]]+)`', $sTag, $aMatches)) {
             $this->_sEndingTags = "</{$aMatches[1]}>" . $this->_sEndingTags;
         }
     }
 }
Exemple #26
0
 public function __construct($cToMode, $cHTMLParsingMode = null)
 {
     if (!in_array($cToMode, array(InterfaceText::PLAIN, InterfaceText::HTML))) {
         throw ExceptionType::domain("Argument #1 doit être égal à Aouka\\Text\\InterfaceText::PLAIN (" . InterfaceText::PLAIN . ") ou Aouka\\Text\\InterfaceText::HTML (" . InterfaceText::HTML . ").", Exception::FROM_HANDLER);
     }
     $this->_cToMode = $cToMode;
     if ($this->_cToMode === InterfaceText::HTML) {
         if ($cHTMLParsingMode !== null) {
             if (!in_array($cHTMLParsingMode, array(String::GLOBAL_PARSING, String::CHUNK_PARSING))) {
                 throw ExceptionType::domain("Argument #2 doit être égal à Aouka\\Text\\String::GLOBAL_PARSING (" . String::GLOBAL_PARSING . ") ou Aouka\\Text\\String::CHUNK_PARSING (" . String::CHUNK_PARSING . ").", Exception::FROM_HANDLER);
             }
             $this->_cToHTMLParsingMode = $cHTMLParsingMode;
         }
     }
 }
Exemple #27
0
 public function __construct($iPadLength, $sPadString = ' ', $iPadType = STR_PAD_RIGHT)
 {
     if (!is_int($iPadLength)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être un entier.", Exception::FROM_HANDLER);
     }
     if (!is_string($sPadString)) {
         throw ExceptionType::invalidArgument("Argument #2 doit être une chaîne de caractères.", Exception::FROM_HANDLER);
     }
     if (!in_array($iPadType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH))) {
         throw ExceptionType::invalidArgument("Argument #3 doit valoir STR_PAD_LEFT ou STR_PAD_RIGHT ou STR_PAD_BOTH.", Exception::FROM_HANDLER);
     }
     $this->_iPadLength = $iPadLength;
     $this->_sPadString = $sPadString;
     $this->_iPadType = $iPadType;
 }
Exemple #28
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;
 }
Exemple #29
0
 /**
  * Effectue la traduction.
  * 
  * @param string $sFormat Type de texte ("html" ou "plain")
  * @return string
  * @throws \Exception
  */
 protected function _process($sFormat)
 {
     $sLangFrom = $this->_getFromLang();
     if ($this->_bUseLocaleFrom && $sLangFrom === $this->_sToLanguage) {
         return $this->_oString->get();
     }
     if (!$this->_getInterpretor()->isTranslatableLang(strtolower($this->_sToLanguage))) {
         throw ExceptionType::domain("La langue de destination n'est pas supportée par le traducteur.", Exception::FROM_HANDLER);
     }
     $this->_getInterpretor()->setLangTo($this->_sToLanguage)->setFormat($sFormat);
     if ($this->_bUseLocaleFrom) {
         $this->setLangFrom($sLangFrom);
     }
     $this->_setNewLocale();
     return $this->_getInterpretor()->translate($this->_oString->get());
 }
Exemple #30
0
 /**
  * Formate sous forme littérale l'expression rationnelle à utiliser.
  * 
  * @return void
  * @throws \Exception
  */
 protected function _formatPattern()
 {
     // Si on reçoit une chaîne de caractères, on la considère comme un pattern valide
     if (is_string($this->_mPattern)) {
         return;
     }
     // Si le pattern est un entier, c'est qu'il s'agit d'une constante
     // on construit alors sa regex
     if (is_int($this->_mPattern)) {
         $this->_mPattern = Regex::create($this->_mPattern);
     }
     // Si le pattern est un objet \Aouka\Regex, on construit l'expression sous sa forme littérale
     if ($this->_mPattern instanceof Regex) {
         $this->_mPattern = '`(' . $this->_mPattern->getExpression() . ')`' . $this->_m();
         return;
     }
     throw ExceptionType::invalidArgument("Le pattern fourni n'est pas correct.", Exception::FROM_HANDLER);
 }