Recommend this page to a friend! |
Classes of Josantonius | PHP Validate | README.md | Download |
|
DownloadPHP Validate libraryPHP simple library for managing of data types.
RequirementsThis library is supported by PHP versions 7.0 or higher and is compatible with HHVM versions 3.0 or higher. InstallationThe preferred way to install this extension is through Composer. To install PHP Validate library, simply:
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
You can also clone the complete repository with Git: $ git clone https://github.com/Josantonius/PHP-Validate.git Or install it manually:
Available MethodsAvailable methods in this library: - Parameter return as array:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as object:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as JSON:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as string:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as integer:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as float:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as boolean:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as IP:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as URL:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value - Parameter return as URL:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $data | Data to convert. | mixed | Yes | | | $default | Default value in error case. | mixed | No | īnullī | # Return (mixed|null) ? value, null or customized return value Quick StartTo use this library with Composer:
Or if you installed it manually, use it:
UsageExample of use for this library: - ARRAY:- When an array is passed:
- When an JSON array is passed:
- When an object is passed:
- When an JSON object is passed:
- Parameter return default value when there's no a correct array:
- OBJECT:- When an object is passed:
- When an JSON object is passed:
- When an array is passed:
- Parameter return default value when there's no a correct object:
- JSON:- When an JSON object is passed:
- When an array is passed:
- When an object is passed:
- Parameter return default value when there's no a correct JSON:
- STRING:- When an string is passed:
- When an integer is passed:
- Parameter return default value when there's no a correct string:
- INTEGER:- When an integer is passed:
- When an string is passed:
- Parameter return default value when there's no a correct integer:
- FLOAT:- When an float is passed:
- When an string is passed:
- Parameter return default value when there's no a correct float:
- BOOLEAN:- When an boolean true is passed:
- When an string true is passed:
- When an integer one is passed:
- When an string one is passed:
- When an boolean false is passed:
- When an string false is passed:
- When an integer zero is passed:
- When an string zero is passed:
- Parameter return default value when there's no a correct boolean:
- IP:- When an IP is passed:
- Parameter return default value when there's no a correct IP:
- URL:- When an URL is passed:
- Parameter return default value when there's no a correct URL:
- Email:- When an email is passed:
- Parameter return default value when there's no a correct email:
TestsTo run tests you just need composer and to execute the following:
Run unit tests with PHPUnit:
Run PSR2 code standard tests with PHPCS:
Run PHP Mess Detector tests to detect inconsistencies in code style:
Run all previous tests:
? TODO
ContributeIf you would like to help, please take a look at the list of issues or the To Do checklist. Pull requests
RepositoryThe file structure from this repository was created with PHP-Skeleton. LicenseThis project is licensed under MIT license. See the LICENSE file for more info. Copyright2018 Josantonius, josantonius.com If you find it useful, let me know :wink: |