<?php
/**
* @version 1.0.0
* @category Anahita Social Engineâ¢
* @copyright Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link http://www.anahitapolis.com
*/
class AnUtilFilterAlias extends KFilterAbstract
{
/**
* Validate a value
*
* @param scalar Value to be validated
* @return bool True when the variable is valid
*/
protected function _validate($value)
{
$value = trim($value);
$pattern = '/[A-Za-z0-9\-_]*$/';
return (is_string($value) && (preg_match($pattern, $value)) == 1);
}
/**
* Sanitize a value
*
* @param mixed Value to be sanitized
* @return string
*/
protected function _sanitize($value)
{
$value = trim($value);
$value = preg_replace('/ /', '-', $value);
$pattern = '/[^A-Za-z0-9\-_]*/';
$value = strtolower(preg_replace($pattern, '', $value));
return $value;
}
}