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; }
public function replaceCallback($sInputString, $fnCallback, $iLimit = -1, &$iCount = 0) { $sString = (string) $sInputString; if (!is_string($sString)) { throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_REGEX); } if (!is_callable($fnCallback)) { throw ExceptionType::badFunctionCall("Argument #2 doit être une fonction de rappel.", Exception::FROM_REGEX); } if (!is_int($iLimit)) { throw ExceptionType::invalidArgument("Argument #3 doit être un entier.", Exception::FROM_REGEX); } return preg_replace_callback($this->_sDelimiter . $this->getExpression() . $this->_sDelimiter . $this->_sModifiers, $fnCallback, $sString, $iLimit, $iCount); }