dev-master
9999999-dev https://github.com/flyandi/php-isA collection of useful is conditions.
MIT
by Andreas Schwarz
Wallogit.com
2017 © Pedro Peláez
A collection of useful is conditions.
Is for PHP is a small library that provides some handy methods to quickly check or validate the contents of a variable., (*1)
Install the library via composer:, (*2)
composer install flyandi/is, (*3)
Pretty straightforward. The library exposes the static class Is that contains all the evaluating methods, e.g.:, (*4)
$AnArray = ['red', 'blue', green]; $AnColor = '#00FF00'; if(Is::_array($AnArray)) echo "Yes, it's an array!"; if(Is::hexcolor($AnColor)) echo "This is a valid color code.";
The Is library implements the following methods currently:, (*5)
| Method | Description |
|---|---|
iterable |
Checks if an object can be iterated, e.g. forEach
|
fn |
Returns true if the argument is an function |
object |
Returns true if the argument is an object |
array |
Returns true if the argument is an array |
string |
Returns true if the argument is an string |
number |
Returns true if the argument is an number |
boolean |
Returns true if the argument is an "true" boolean, e.g. TRUE or FALSE
|
defined |
Returns true if the argument is defined, e.g. not undefined
|
empty |
Returns true if the argument is really empty |
same |
Returns true if two arguments are equal, e.g. Is.same('1', '1');
|
associated |
Returns true if the argument is an associated array |
sequential |
Returns true if the argument is an sequential array |
Additionally the library also provides some basic validation expression filters:, (*6)
| Method | Description |
|---|---|
url |
Returns true if the argument contains a URL |
email |
Returns true if the argument contains an E-Mail |
creditcard |
Returns true if the argument contains an Credit Card Number |
alphanumeric |
Returns true if the argument contains an Alpha Numeric string |
time |
Returns true if the argument contains an time |
datestring |
Returns true if the argument contains an date string |
zip |
Returns true if the argument contains an ZIP Code |
phone |
Returns true if the argument contains a US Phone Number |
ssn |
Returns true if the argument contains a Social Security Number |
affirmative |
Returns true if the argument contains True, Yes or Ok |
hexadecimal |
Returns true if the argument contains a hexadecimal string |
hexcolor |
Returns true if the argument contains an HTML color |
This library was originally written in JavaScript for Meteor (http://github.com/flyandi/meteor-is) and implements the same methods and filters., (*7)
A collection of useful is conditions.
MIT