jawira/sanitizer

😷 Sanitize your objects with attributes.

v1.0.0 2023-08-15 21:26 UTC

This package is auto-updated.

Last update: 2024-06-14 21:49:40 UTC


README

😷 jawira/sanitizer

Sanitize your objects with attributes.

Latest Stable Version Total Downloads PHP Version Require License

Usage

Add sanitizer attributes to your class:

use Jawira\Sanitizer\Cleaners 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...