Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/italystrap/cleaner
Data cleaner for PHP
https://github.com/italystrap/cleaner
php wordpress-php-library
Last synced: about 1 month ago
JSON representation
Data cleaner for PHP
- Host: GitHub
- URL: https://github.com/italystrap/cleaner
- Owner: ItalyStrap
- License: mit
- Created: 2019-10-14T10:41:55.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-27T12:49:40.000Z (about 5 years ago)
- Last Synced: 2024-04-15T22:10:51.591Z (9 months ago)
- Topics: php, wordpress-php-library
- Language: PHP
- Homepage: https://italystrap.com
- Size: 253 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ItalyStrap Cleaner API
[![Build Status](https://travis-ci.org/ItalyStrap/cleaner.svg?branch=master)](https://travis-ci.org/ItalyStrap/cleaner)
[![Latest Stable Version](https://img.shields.io/packagist/v/italystrap/cleaner.svg)](https://packagist.org/packages/italystrap/cleaner)
[![Total Downloads](https://img.shields.io/packagist/dt/italystrap/cleaner.svg)](https://packagist.org/packages/italystrap/cleaner)
[![Latest Unstable Version](https://img.shields.io/packagist/vpre/italystrap/cleaner.svg)](https://packagist.org/packages/italystrap/cleaner)
[![License](https://img.shields.io/packagist/l/italystrap/cleaner.svg)](https://packagist.org/packages/italystrap/cleaner)
![PHP from Packagist](https://img.shields.io/packagist/php-v/italystrap/cleaner)PHP Sanitizer and Validation OOP way
## Table Of Contents
* [Installation](#installation)
* [Basic Usage](#basic-usage)
* [Advanced Usage](#advanced-usage)
* [Contributing](#contributing)
* [License](#license)## Installation
The best way to use this package is through Composer:
```CMD
composer require italystrap/cleaner
```## Basic Usage
```php
$sanitizator = new \ItalyStrap\Cleaner\Sanitization();
$validator = new \ItalyStrap\Cleaner\Validation();$sanitizator->addRules( 'trim' );
// `Test`
echo $sanitizator->sanitize( ' Test ' );// Single string rule
$rule = 'trim';
$sanitizator->addRules( $rule );
// `Test`
echo $sanitizator->sanitize( ' Test ' );// Multiple rules in string
$rules = 'strip_tags|trim';
$sanitizator->addRules( $rules );
// `Test`
echo $sanitizator->sanitize( 'Test
' );// Multiple rules string in array
$rules_arr = [
'strip_tags',
'trim',
];
$sanitizator->addRules( $rules_arr );
// `Test`
echo $sanitizator->sanitize( 'Test
' );$callback = function ( $value ) {
return 'New value from callback';
};// Callable rule in array
$rule_callable = [
$callback
];
$sanitizator->addRules( $rule_callable );
// `New value from callback`
echo $sanitizator->sanitize( 'Test
' );// Multiple callable rules in array
$rules_callable = [
$callback,
$callback,
];
$sanitizator->addRules( $rules_callable );
// `New value from callback`
echo $sanitizator->sanitize( 'Test
' );
```
Every ::sanitize() or ::validate() call will reset the rules provided.
Make sure you provide new rule befor calling ::sanitize() or ::validate().## Advanced Usage
> TODO
## Contributing
All feedback / bug reports / pull requests are welcome.
## License
Copyright (c) 2019 Enea Overclokk, ItalyStrap
This code is licensed under the [MIT](LICENSE).
## Credits
> TODO