Throwing an exception seems a bit extreme, since a line that does not check is not really an exception to the string check package.
As such, I would think that returning the false would be the most logical solution. In addition, you can also pass a significant textual error through a reference variable, if that makes sense with respect to your implementation.
For instance:
// In the class definition... public function validateSTring($stringToValidate, &$errorString=null) { // If an error occurs... if($errorString) { $errorString = 'Something went wrong along the way.'; return false; } } // When calling... $errorString = ''; $validationSuite->validateString($stringToValidate, $errorString);
source share