Last updated: August 12th, 2023

The SanitationHelper class provides some basic sanitizers for scalar types and the interfaces to build custom sanitatizers.


use Stoic\Utilities\SanitationHelper;
use Stoic\Utilities\Sanitizers;

// This sanitizer turns EVERYTHING into the string "Bob"
class BobSanitizer implements SanitizerInterface {
	public function sanitize($input) {
		return "Bob";

$sani = new SanitationHelper();
$sani->addSanitizer('bob', BobSanitizer::class);

echo($sani->sanitize(23, 'bob'));       // Bob
echo($sani->sanitize(true, 'bob'));     // Bob
echo($sani->sanitize('Robert', 'bob')); // Bob!

Further Reading

Next Up

Continue to read about the StringHelper class, or visit the Table of Contents.