| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | 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.
|  Files (32) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  docs (1 file) | ||||
|  src (2 files, 1 directory) | ||||
|  tests (1 directory) | ||||
|    .editorconfig | Data | Auxiliary data | ||
|    .php-cs-fixer.php | Example | Example script | ||
|    build.xml | Data | Auxiliary data | ||
|    composer.json | Data | Auxiliary data | ||
|    LICENSE.md | Lic. | License text | ||
|    phpunit.xml | Data | Auxiliary data | ||
|    psalm.xml | Data | Auxiliary data | ||
|    README.md | Doc. | Documentation | ||
|  Files (32) | / | src | 
| File | Role | Description | ||
|---|---|---|---|---|
|  Filters (11 files) | ||||
|  SanitizerInterface.php | Class | Class source | ||
|  SanitizerService.php | Class | Class source | ||
|  Files (32) | / | src | / | Filters | 
| File | Role | Description | 
|---|---|---|
|  Ascii.php | Class | Class source | 
|  Capitalize.php | Class | Class source | 
|  FilterInterface.php | Class | Class source | 
|  GteZero.php | Class | Class source | 
|  IntegerChars.php | Class | Class source | 
|  Lowercase.php | Class | Class source | 
|  LteZero.php | Class | Class source | 
|  Pad.php | Class | Class source | 
|  StripTags.php | Class | Class source | 
|  Trim.php | Class | Class source | 
|  Uppercase.php | Class | Class source | 
|  Files (32) | / | tests | / | UnitTests | 
| File | Role | Description | 
|---|---|---|
|  AsciiTest.php | Class | Class source | 
|  CapitalizeTest.php | Class | Class source | 
|  GteZeroTest.php | Class | Class source | 
|  IntegerTest.php | Class | Class source | 
|  LowercaseTest.php | Class | Class source | 
|  LteZeroTest.php | Class | Class source | 
|  PadTest.php | Class | Class source | 
|  StripTagsTest.php | Class | Class source | 
|  TrimTest.php | Class | Class source | 
|  UppercaseTest.php | 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. | 
|  Install with Composer | 
| 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.
 If you know an application of this package, send a message to the author to add a link here.