Sanitizer
App\Shared\Services\Sanitizer
Method | Description | Type | Parameters | Return |
---|---|---|---|---|
__construct | public | |||
validateItems | Validates an array of items (if needed) |
public static |
array $items Items to validate | bool True if valid, false otherwise |
items | Sanitizes an array of items according to the self::$sanitize[] Sanitize will be standard of type string, but can also be specified For ease of use, this syntax is accepted: $sanitize = ['fieldname', 'otherfieldname' => 'float']; $this->items($sanitize); throws Exception throws ReflectionException |
public static |
array $items Items to sanitize string $context The context for which the string is being sanitized |
array Sanitized items |
addError | Adds an error to the errors array | protected static |
||
item | Sanitizes an item according to type throws Exception throws ReflectionException |
public static |
mixed $item Item to sanitize string $type Item type (ie string, float, int, etc) string $context The context for which the string is being sanitized |
string null Sanitized string or null if item is empty |
validateItem | Validates a single item according to $type |
public static |
mixed $item Item to validate string $type Item type (ie string, float, int, etc) |
bool True if valid, false otherwise |
key | Sanitizes a string key Keys are used as internal identifiers Lowercase alphanumeric characters, dashes and underscores are allowed Uses sanitize_key filter hookthrows Exception throws ReflectionException |
public static |
string $key String key | string Sanitized key |
username | Sanitizes a username, stripping out unsafe characters Removes tags, octets, entities, and if strict is enabled, will only keep alphanumeric, _, space, , -, After sanitizing, it passes the username, raw username (the username in the parameter), and the value of $strict as throws Exception throws ReflectionException |
public static |
parameters for the sanitize_user filterstring $username The username to be sanitized bool $strict If set, limits $username to specific characters Default false |
string The sanitized username, after passing through filters |
removeAccents | public static |