romeoz/rock-sanitize

Flexible sanitizator for PHP.

0.11.1 2015-11-07 05:01 UTC

README

Latest Stable Version Total Downloads Build Status HHVM Status Coverage Status License

Features

  • Sanitization of scalar variable, array and object
  • Custom rules
  • Standalone module/component for Rock Framework

Installation

From the Command Line:

composer require romeoz/rock-sanitize

In your composer.json:

{
    "require": {
        "romeoz/rock-sanitize": "*"
    }
}

Quick Start

use rock\sanitize\Sanitize;

Sanitize::removeTags()
    ->lowercase()
    ->sanitize('<b>Hello World!</b>');
// output: hello world!    

####As Array or Object

use rock\sanitize\Sanitize;

$input = [
    'name' => '<b>Tom</b>',
    'age' => -22
];

$attributes = [
    'name' => Sanitize::removeTags(),
    'age' => Sanitize::abs()
];
        
Sanitize::attributes($attributes)->sanitize($input);
/*
output:

[
  'name' => 'Tom',
  'age' => 22
]
*/

// all attributes:
Sanitize::attributes(Sanitize::removeTags())->sanitize($input);

Documentation

Demo

Requirements

  • PHP 5.4+

License

The Rock Sanitize is open-sourced software licensed under the MIT license.