Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 101 | All time: 9,798 This week: 57![]() |
Version | License | PHP version | Categories | |||
jawira-sanitizer 1.0 | Custom (specified... | 7 | Text processing, Validation, PHP 7 |
Sanitize your classes using attributes.
Add sanitizer attributes to your class:
use Jawira\Sanitizer\Filters as Sanitizer;
class User {
#[Sanitizer\Trim]
#[Sanitizer\Capitalize]
public string $name;
}
Call SanitizerService::sanitize
method to apply sanitizers:
use Jawira\Sanitizer\SanitizerService;
$sanitizer = new SanitizerService();
$user = new User();
$user->name = ' BOB ';
$sanitizer->sanitize($user);
echo $user->name; // After: 'Bob'
| Sanitizer | Works with | Description | |------------------|----------------|-----------------------------------------------------------------------------------------| | Ascii | _string_ | Remove all characters except ascii characters. | | Capitalize | _string_ | Converts the first letter of each word to uppercase and leaves the others as lowercase. | | GteZero | _int_, _float_ | Ensures number is greater than or equal to zero. | | IntegerChars | _string_ | Remove all characters except digits, plus and minus sign. | | Lowercase | _string_ | Make a string lowercase. | | LteZero | _int_, _float_ | Ensures number is lower than or equal to zero. | | Pad | _string_ | Pad a string to a certain length with another string. | | StripTags | _string_ | Strip HTML and PHP tags from a string. | | Trim | _string_ | Strip whitespace (or other characters) from the beginning and end of a string. | | Uppercase | _string_ | Make a string uppercase. |
composer require jawira/sanitizer
You must not solely rely on sanitization, you must implement a proper data validation mechanism.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | src |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
Class | Class source | ||
![]() |
Class | Class source |
![]() |
/ | src | / | Filters |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | tests | / | UnitTests |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.