tfarla/want-type

一个简单的PHP验证工具

该软件包的官方仓库似乎已不存在,因此该软件包已被冻结。

dev-master 2014-08-04 08:51 UTC

This package is auto-updated.

Last update: 2020-10-16 12:27:07 UTC


README

Build Status

一个简单的PHP类型工具

安装

composer require tfarla/want-type dev-master

使用

// Returns null
Want\string('s');
Want\string('s', 't', 'r', 'i', 'n', 'g');

// Throws InvalidArgumentException
Want\string(true);

// Returns null
Want\collectionOf('string', array('s'))
Want\collectionOf('string', array('s'), array('t'))

// Throws InvalidArgumentException
Want\collectionOf('string', array(1))

##函数

\Want\bool(...)
\Want\collection(...)
\Want\collectionOf(type, ...)
\Want\double(...)
\Want\float(...)
\Want\instance('class', ...)
\Want\int(...)
\Want\invokable(...)
\Want\null(...)
\Want\numeric(...)
\Want\object(...)
\Want\resource(...)
\Want\scalar(...)
\Want\string(...)