taobig/php-filter

PHP项目类型验证和过滤插件

v0.3.0 2022-06-10 14:05 UTC

This package is auto-updated.

Last update: 2024-09-10 19:04:24 UTC


README

php-filter

PHP项目类型验证和过滤插件

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

安装

通过Composer安装
如果您没有Composer,您可以参考 getcomposer.org 安装它。

然后您可以使用以下命令安装此项目模板

php composer.phar require taobig/php-filter

用法

use taobig\filter\filters\TypeValidator;
TypeValidator::isString("hello world");//return true
TypeValidator::isString(1111.32333, false);//return true
TypeValidator::isInt(1111);//return true
TypeValidator::isInt("1111", false);//return true
TypeValidator::isIntList([1111]);//return true
TypeValidator::isIntList(["1111"], false);//return true
TypeValidator::isStringList(["1111"]);//return true
TypeValidator::isStringList([1111], false);//return true


$filter = new taobig\filter\filters\TypeFilter(['exceptionMessage'=>'parameters type error']);
$filter->stringVal("hello world");//return "hello world"
$filter->stringVal(1111.32333, false);//return "1111.32333"
$filter->intVal("1111", false);//return 1111

use taobig\filter\filters\MobileValidator;  
TypeValidator::isChineseMobile("13800001111");//return true