jawira/sanitizer

😷 Sanitize your objects with attributes.

v2.0.0 2024-10-15 17:48 UTC

This package is auto-updated.

Last update: 2024-11-30 20:32:50 UTC


README

Sanitize your objects with attributes.

Latest Stable Version Total Downloads PHP Version Require License

Usage

Add sanitizer attributes to your class:

use Jawira\Sanitizer\Attribute as Filter;

class User {
    #[Filter\Trim]
    #[Filter\Title]
    public string $name;
}

Call Sanitizer::sanitize method to apply sanitizers:

use Jawira\Sanitizer\Sanitizer;

$user = new User();
$user->name = ' BOB ';

$sanitizer = new Sanitizer();
$sanitizer->sanitize($user);

echo $user->name; // 'Bob'

Interface SanitizerInterface is also available.

Documentation

https://jawira.github.io/sanitizer/

Install

composer require jawira/sanitizer

Security

Warning
Sanitization is not a replacement for a proper data validation mechanism and database constraints.

License

This library is licensed under the MIT license.

Packages from jawira

jawira/doctrine-diagram-bundle GitHub stars
Symfony Bundle to generate database diagrams.
jawira/case-converter GitHub stars
Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.
jawira/emoji-catalog GitHub stars
Get access to +3000 emojis as class constants.
more...